ASL
Loading...
Searching...
No Matches
Testing

Detailed Description

Tiny testing functionality.

The ASL_TEST_ENABLE_MAIN() macro adds testing functionality and creates a main function that runs all defined tests. Use the ASL_TEST_ENABLE() macro if you will provide your own main function.

#include <asl/testing.h>
{
Car car;
ASL_ASSERT(car.isStopped());
ASL_EXPECT(car.numWheels(), >, 2);
}
ASL_TEST(Volume)
{
Sphere sphere(1.0);
ASL_EXPECT_NEAR(sphere.volume(), 4.1888, 1e-3);
}
#define ASL_EXPECT(x, op, y)
Check a condition with the given operator and operands.
Definition testing.h:191
#define ASL_EXPECT_NEAR(x, y, d)
Check that x and y are approximately equal (within distance d).
Definition testing.h:203
#define ASL_TEST(Name)
Create a test named Name.
Definition testing.h:107
#define ASL_TEST_ENABLE_MAIN()
Add support for testing in this executable and create a function main() that runs all tests.
Definition testing.h:99

Macros

#define ASL_TEST_ENABLE()
 Add support for testing in this executable (use only once in the sources for one executable).
 
#define ASL_TEST_ENABLE_MAIN()
 Add support for testing in this executable and create a function main() that runs all tests.
 
#define ASL_TEST(Name)
 Create a test named Name.
 
#define ASL_ASSERT(x)
 Check that the argument is true.
 
#define ASL_EXPECT(x, op, y)
 Check a condition with the given operator and operands.
 
#define ASL_EXPECT_NEAR(x, y, d)
 Check that x and y are approximately equal (within distance d).
 

Functions

bool runTest (const char *name)
 Runs the test named name.
 
bool runAllTests ()
 Runs all tests and returns true if all succeded; prints results to console or appends them to testResult on Android.
 

Macro Definition Documentation

◆ ASL_EXPECT

#define ASL_EXPECT (   x,
  op,
 
)

Check a condition with the given operator and operands.

ASL_EXPECT(sqrt(x), >=, 0);