Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FunctionObject_UnitTests.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
13 
14 
15 namespace Teuchos{
16 
20 TEUCHOS_UNIT_TEST(Teuchos_Functions, SubtractionTests){
21  SubtractionFunction<int> intTester(10);
22  TEST_ASSERT(intTester.runFunction(10) == 0);
23  TEST_ASSERT(intTester.runFunction(-10) == -20);
24 
25  SubtractionFunction<double> doubleTester(5.5);
26  TEST_ASSERT(doubleTester.runFunction(10) == 4.5);
27 }
28 
32 TEUCHOS_UNIT_TEST(Teuchos_Functions, AdditionTests){
33  AdditionFunction<int> intTester(10);
34  TEST_ASSERT(intTester.runFunction(10) == 20);
35  TEST_ASSERT(intTester.runFunction(-10) == 0);
36 
37  AdditionFunction<double> doubleTester(5.5);
38  TEST_ASSERT(doubleTester.runFunction(10) == 15.5);
39 }
40 
44 TEUCHOS_UNIT_TEST(Teuchos_Functions, MultiplicationTests){
45  MultiplicationFunction<int> intTester(10);
46  TEST_ASSERT(intTester.runFunction(10) == 100);
47  TEST_ASSERT(intTester.runFunction(-10) == -100);
48 
49  MultiplicationFunction<double> doubleTester(5.5);
50  TEST_ASSERT(doubleTester.runFunction(10) == 55);
51 }
52 
56 TEUCHOS_UNIT_TEST(Teuchos_Functions, DivisionTests){
57  DivisionFunction<int> intTester(10);
58  TEST_ASSERT(intTester.runFunction(100) == 10);
59  TEST_ASSERT(intTester.runFunction(-10) == -1);
60 
61  DivisionFunction<double> doubleTester(2);
62  TEST_ASSERT(doubleTester.runFunction(7.5) == 3.75);
63 }
64 
65 
66 
67 } //namespace Teuchos
68 
#define TEST_ASSERT(v1)
Assert the given statement is true.
TEUCHOS_UNIT_TEST(ConstNonconstObjectContainer, create)
Unit testing support.