Skip to content
Snippets Groups Projects
  • Nick Draper's avatar
    ef3ccb58
    Merge pull request #23693 from mantidproject/23488_update_file_headers · ef3ccb58
    Nick Draper authored
    Update copyright headers in all files
    
    Squashed commit of the following:
    
    * First version of a script to manage copyright statements
    
    re #23468
    
    * Neatened up script, added comments
    
    re #23488
    
    * move script to tools directory
    
    re #23488
    
    * small script changes and a couple of manual file changes
    
    re #23488
    
    * Minor chnage to whitespace detection in regex
    
    re #23488
    
    * Add an excluded directory
    
    re #23488
    
    * remove a repeasted copyright statement in a file
    
    re #23488
    
    * Don't comsume the comment end if it is on the same line
    
    re #23488
    
    * fix error in new copright parsing
    
    re #23488
    
    * remove double copyrifght entry
    
    re #23488
    
    * Improve handling of old copyrights at the start of comments
    
    re #23488
    
    * remove empty comments re #23488
    
    * exclude gsoapgenerated directories
    
    re #23488
    
    * Sort out greedy line matching re #23488
    
    * improve empty comment removal
    
    re #23488
    
    * improve false positives
    
    re #23488
    
    * impressive speedup by limiting regex matching length
    
    re #23488
    
    * remove evil invisible non ascii character
    
    Also upadte the copyright at the same time
    
    re #23488
    
    * resolve multiple copyrights in a single file
    
    re #23488
    
    * resolve an issue with new statement detection
    
    re #23488
    
    * another unprintable unicode character
    
    re #23488
    
    * pep updates and cmake the new copyright fit clang format
    
    re #23488
    
    * update already done new format headers
    
    re #23488
    
    * wrong type of bracket
    
    re #23488
    
    * Update class_maker and friends
    
    re #23488
    
    * Update all copyright statements
    
    re #23488
    
    * clang format re #23488
    
    * flake8 warnings re #23488
    
    * Flake8 warnings re #23488
    
    * Exclude .cmake.in and rb.in files
    
    re #23488
    
    * replace missing line re #23488
    
    * exclude .py.in files as they are flasely recognized as C++
    
    re #23488
    
    * another setp.py.in re #23488
    
    * another .py.in correction re #23488
    
    * Hopefully the last of the .py.in files re #23488
    
    * resolve utf-8 encoding of python files and changed ABINS checksum
    
    re #23488
    
    * updates to unit tests that reference line numbers
    
    re #23488
    
    * remaining unit test files and other fixes
    
    re #23488
    ef3ccb58
    History
    Merge pull request #23693 from mantidproject/23488_update_file_headers
    Nick Draper authored
    Update copyright headers in all files
    
    Squashed commit of the following:
    
    * First version of a script to manage copyright statements
    
    re #23468
    
    * Neatened up script, added comments
    
    re #23488
    
    * move script to tools directory
    
    re #23488
    
    * small script changes and a couple of manual file changes
    
    re #23488
    
    * Minor chnage to whitespace detection in regex
    
    re #23488
    
    * Add an excluded directory
    
    re #23488
    
    * remove a repeasted copyright statement in a file
    
    re #23488
    
    * Don't comsume the comment end if it is on the same line
    
    re #23488
    
    * fix error in new copright parsing
    
    re #23488
    
    * remove double copyrifght entry
    
    re #23488
    
    * Improve handling of old copyrights at the start of comments
    
    re #23488
    
    * remove empty comments re #23488
    
    * exclude gsoapgenerated directories
    
    re #23488
    
    * Sort out greedy line matching re #23488
    
    * improve empty comment removal
    
    re #23488
    
    * improve false positives
    
    re #23488
    
    * impressive speedup by limiting regex matching length
    
    re #23488
    
    * remove evil invisible non ascii character
    
    Also upadte the copyright at the same time
    
    re #23488
    
    * resolve multiple copyrights in a single file
    
    re #23488
    
    * resolve an issue with new statement detection
    
    re #23488
    
    * another unprintable unicode character
    
    re #23488
    
    * pep updates and cmake the new copyright fit clang format
    
    re #23488
    
    * update already done new format headers
    
    re #23488
    
    * wrong type of bracket
    
    re #23488
    
    * Update class_maker and friends
    
    re #23488
    
    * Update all copyright statements
    
    re #23488
    
    * clang format re #23488
    
    * flake8 warnings re #23488
    
    * Flake8 warnings re #23488
    
    * Exclude .cmake.in and rb.in files
    
    re #23488
    
    * replace missing line re #23488
    
    * exclude .py.in files as they are flasely recognized as C++
    
    re #23488
    
    * another setp.py.in re #23488
    
    * another .py.in correction re #23488
    
    * Hopefully the last of the .py.in files re #23488
    
    * resolve utf-8 encoding of python files and changed ABINS checksum
    
    re #23488
    
    * updates to unit tests that reference line numbers
    
    re #23488
    
    * remaining unit test files and other fixes
    
    re #23488
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
DiffractionTest.h 3.14 KiB
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
//     NScD Oak Ridge National Laboratory, European Spallation Source
//     & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#ifndef MANTID_KERNEL_DIFFRACTIONTEST_H_
#define MANTID_KERNEL_DIFFRACTIONTEST_H_

#include <cxxtest/TestSuite.h>
#include <limits>

#include "MantidKernel/Diffraction.h"

using Mantid::Kernel::Diffraction::calcTofMax;
using Mantid::Kernel::Diffraction::calcTofMin;

namespace {                // anonymous
const double DIFC = 2100.; // sensible value
const double TZERO = 10.;
// intentionally goofy - reduces tzero by 1
const double DIFA1 = .25 * DIFC * DIFC;
// intentionally goofy - reduces tzero by .01
const double DIFA2 = 25 * DIFC * DIFC;
// intentionally goofy
const double DIFA3 = -.25 * DIFC * DIFC;
} // namespace

class DiffractionTest : public CxxTest::TestSuite {
public:
  // This pair of boilerplate methods prevent the suite being created statically
  // This means the constructor isn't called when running other tests
  static DiffractionTest *createSuite() { return new DiffractionTest(); }
  static void destroySuite(DiffractionTest *suite) { delete suite; }

  void test_calcTofMin() {
    const double TMIN = 300.;

    // just difc
    TS_ASSERT_EQUALS(calcTofMin(DIFC, 0., 0.), 0.);
    TS_ASSERT_EQUALS(calcTofMin(DIFC, 0., 0., TMIN), TMIN);
    // difc + tzero
    TS_ASSERT_EQUALS(calcTofMin(DIFC, 0., TZERO, 0.), TZERO);
    TS_ASSERT_EQUALS(calcTofMin(DIFC, 0., TZERO, TMIN), TMIN);

    // difc + difa + tzero
    TS_ASSERT_EQUALS(calcTofMin(DIFC, DIFA1, 0., 0.), 0.);
    TS_ASSERT_EQUALS(calcTofMin(DIFC, DIFA1, 0., TMIN), TMIN);
    TS_ASSERT_EQUALS(calcTofMin(DIFC, DIFA1, TZERO, 0.), TZERO - 1.);
    TS_ASSERT_EQUALS(calcTofMin(DIFC, DIFA1, TZERO, TMIN), TMIN);

    TS_ASSERT_EQUALS(calcTofMin(DIFC, DIFA2, 0., 0.), 0.);
    TS_ASSERT_EQUALS(calcTofMin(DIFC, DIFA2, 0., TMIN), TMIN);
    TS_ASSERT_EQUALS(calcTofMin(DIFC, DIFA2, TZERO, 0.), TZERO - .01);
    TS_ASSERT_EQUALS(calcTofMin(DIFC, DIFA2, TZERO, TMIN), TMIN);
  }

  void test_calcTofMax() {
    const double TMAX = 16666.7;
    const double TSUPERMAX = std::numeric_limits<double>::max();

    // just difc
    TS_ASSERT_EQUALS(calcTofMax(DIFC, 0., 0., TMAX), TMAX);
    TS_ASSERT_EQUALS(calcTofMax(DIFC, 0., 0., TSUPERMAX), TSUPERMAX);
    // difc + tzero
    TS_ASSERT_EQUALS(calcTofMax(DIFC, 0., TZERO, TMAX), TMAX);
    TS_ASSERT_EQUALS(calcTofMax(DIFC, 0., TZERO, TSUPERMAX), TSUPERMAX);

    // difc + difa + tzero
    TS_ASSERT_EQUALS(calcTofMax(DIFC, DIFA1, 0., TMAX), TMAX);
    TS_ASSERT_EQUALS(calcTofMax(DIFC, DIFA1, 0., TSUPERMAX), TSUPERMAX);
    TS_ASSERT_EQUALS(calcTofMax(DIFC, DIFA1, TZERO, TMAX), TMAX);
    TS_ASSERT_EQUALS(calcTofMax(DIFC, DIFA1, TZERO, TSUPERMAX), TSUPERMAX);

    TS_ASSERT_EQUALS(calcTofMax(DIFC, DIFA3, 0., TMAX), 0.);
    TS_ASSERT_EQUALS(calcTofMax(DIFC, DIFA3, 0., TSUPERMAX), 0.);
    TS_ASSERT_EQUALS(calcTofMax(DIFC, DIFA3, TZERO, TMAX), TZERO - 1.);
    TS_ASSERT_EQUALS(calcTofMax(DIFC, DIFA3, TZERO, TSUPERMAX), TZERO - 1.);
  }
};

#endif /* MANTID_KERNEL_DIFFRACTIONTEST_H_ */