Created
January 8, 2023 17:40
-
-
Save erincatto/b51e64e5cb9dd1a5c9fc70c4005f6e8e to your computer and use it in GitHub Desktop.
Revisions
-
erincatto created this gist
Jan 8, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ // SPDX-FileCopyrightText: 2022 Erin Catto // SPDX-License-Identifier: MIT #include <stdbool.h> #include <stdio.h> #include <assert.h> #define RUN_TEST(T) \ do { \ int result = T(); \ if (result == 1) \ { \ printf("test failed: " #T "\n"); \ return 1; \ } \ else \ { \ printf("test passed: " #T "\n"); \ } \ } while (false) #define RUN_SUBTEST(T) \ do { \ int result = T(); \ if (result == 1) \ { \ printf(" subtest failed: " #T "\n"); \ return 1; \ } \ else \ { \ printf(" subtest passed: " #T "\n"); \ } \ } while (false) #define ENSURE(C) \ do { \ if ((C) == false) \ { \ printf("condition false: " #C "\n"); \ assert(false); \ return 1; \ } \ } while (false) #define ENSURE_SMALL(C, tol) \ do { \ if ((C) < -(tol) || (tol) < (C)) \ { \ printf("condition false: abs(" #C ") < %g\n", tol); \ assert(false); \ return 1; \ } \ } while (false)