Skip to content

Commit

Permalink
coda-oss 2022-05-03
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith committed May 3, 2022
1 parent 2bc2533 commit 2323c32
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
6 changes: 4 additions & 2 deletions externals/coda-oss/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
```
# coda-oss Release Notes

## WIP: (Release 202?-??-??)
## Release 2022-05-03
* Fixed a bug in `Poly2D::atY()`; imporved `flipXY()` behavior.
* Implement [std::filesystem::file_size()](https://en.cppreference.com/w/cpp/filesystem/file_size).
* use `inline` functions for `TEST_` macros
* use `inline` functions for `TEST_` macros
* force use of [64-bit `time_t`](https://en.wikipedia.org/wiki/Year_2038_problem)
* more routines now support a `std::span` overload; e.g., `io::InputStream::read()`.

## (Release 2022-02-22)
* new `EnocdedString` and `EncodedStringView` to manage strings in different encodings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ static_assert(CODA_OSS_MAKE_VERSION_MMPB(9999, 9999, 9999, 9999) <= UINT64_MAX,

// Do this ala C++ ... we don't currently have major/minor/patch
//#define CODA_OSS_VERSION_ 20210910L // c.f. __cplusplus
#define CODA_OSS_VERSION_ 2022 ## 0002 ## 0022 ## 0000 ## L
#define CODA_OSS_VERSION_ 2022 ## 0005 ## 0003 ## 0000 ## L

// Use the same macros other projects might want to use; overkill for us.
#define CODA_OSS_VERSION_MAJOR 2022
#define CODA_OSS_VERSION_MINOR 2
#define CODA_OSS_VERSION_PATCH 22
#define CODA_OSS_VERSION_MINOR 5
#define CODA_OSS_VERSION_PATCH 3
#define CODA_OSS_VERSION_BUILD 0
#define CODA_OSS_VERSION CODA_OSS_MAKE_VERSION_MMPB(CODA_OSS_VERSION_MAJOR, CODA_OSS_VERSION_MINOR, CODA_OSS_VERSION_PATCH, CODA_OSS_VERSION_BUILD)

Expand Down
25 changes: 18 additions & 7 deletions externals/coda-oss/modules/c++/include/TestCase.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ inline void test_assert_true(TX&& X, const std::string& testName, const char* f
}
}

// These cause warnings (or even errors, depending on compile settings) if the types have different signedness.
// assert_eq(v.size(), 1, ...);
/*
template<typename TX1, typename TX2>
inline void assert_eq(TX1&& X1, TX2&& X2,
const std::string& testName, const char* file, const char* func, int line)
Expand All @@ -118,7 +121,6 @@ inline void assert_eq(TX1&& X1, TX2&& X2,
diePrintf("%s (%s,%s,%d): FAILED: Recv'd %s, Expected %s\n", testName, file, func, line, X1, X2);
}
}

template<typename TX1, typename TX2>
inline void assert_eq_msg(const std::string& msg, TX1&& X1, TX2&& X2,
const std::string& testName, const char* file, int line)
Expand All @@ -139,6 +141,7 @@ inline void assert_not_eq(TX1&& X1, TX2&& X2,
diePrintf("%s (%s,%s,%d): FAILED: Recv'd %s should not equal %s\n", testName, file, func, line, X1, X2);
}
}
*/
template<typename TX1, typename TX2, typename TEPS>
inline void assert_almost_eq_eps(TX1&& X1, TX2&& X2, TEPS&& EPS,
const std::string& testName, const char* file, const char* func, int line)
Expand All @@ -149,7 +152,6 @@ inline void assert_almost_eq_eps(TX1&& X1, TX2&& X2, TEPS&& EPS,
diePrintf("%s (%s,%d): FAILED: Recv'd %s, Expected %s\n", testName, file, func, line, X1, X2);
}
}

template<typename TX1, typename TX2>
inline void assert_almost_eq(TX1&& X1, TX2&& X2,
const std::string& testName, const char* file, const char* func, int line)
Expand All @@ -160,7 +162,7 @@ inline void assert_almost_eq(TX1&& X1, TX2&& X2,
diePrintf("%s (%s,%s,%d): FAILED: Recv'd %s, Expected %s\n", testName, file, func, line, X1, X2);
}
}

/*
template<typename TX1, typename TX2>
inline void assert_greater_eq(TX1&& X1, TX2&& X2,
const std::string& testName, const char* file, const char* func, int line)
Expand Down Expand Up @@ -200,7 +202,7 @@ inline void assert_lesser(TX1&& X1, TX2&& X2,
diePrintf("%s (%s,%s,%d): FAILED: Value should be less than\n", testName, file, func, line);
}
}

*/
template<typename Tmsg>
inline void fail(Tmsg&& msg,
const std::string& testName, const char* file, const char* func, int line)
Expand Down Expand Up @@ -254,7 +256,7 @@ inline void specific_exception(TFunc f,
}

template <typename TFunc>
inline int main(int argc, char** argv, TFunc f)
inline int main(TFunc f)
{
try
{
Expand All @@ -281,22 +283,26 @@ inline int main(int argc, char** argv, TFunc f)
#define TEST_ASSERT_NULL(X) coda_oss::test::assert_null(X, testName, __FILE__, SYS_FUNC, __LINE__)
#define TEST_ASSERT_FALSE(X) coda_oss::test::test_assert_false(X, testName, __FILE__, SYS_FUNC, __LINE__)
#define TEST_ASSERT_TRUE(X) coda_oss::test::test_assert_true(X, testName, __FILE__, SYS_FUNC, __LINE__)
/*
#define TEST_ASSERT_EQ(X1, X2) coda_oss::test::assert_eq(X1, X2, testName, __FILE__, SYS_FUNC, __LINE__)
#define TEST_ASSERT_EQ_MSG(msg, X1, X2) coda_oss::test::assert_eq_msg(msg, X1, X2, testName, __FILE__, __LINE__)
#define TEST_ASSERT_NOT_EQ(X1, X2) coda_oss::test::assert_not_eq(X1, X2, testName, __FILE__, SYS_FUNC, __LINE__)
*/
#define TEST_ASSERT_ALMOST_EQ_EPS(X1, X2, EPS) coda_oss::test::assert_almost_eq_eps(X1, X2, EPS, testName, __FILE__, SYS_FUNC, __LINE__)
#define TEST_ASSERT_ALMOST_EQ(X1, X2) coda_oss::test::assert_almost_eq(X1, X2, testName, __FILE__, SYS_FUNC, __LINE__)
/*
#define TEST_ASSERT_GREATER_EQ(X1, X2) coda_oss::test::assert_greater_eq(X1, X2, testName, __FILE__, SYS_FUNC, __LINE__)
#define TEST_ASSERT_GREATER(X1, X2) coda_oss::test::assert_greater(X1, X2, testName, __FILE__, SYS_FUNC, __LINE__)
#define TEST_ASSERT_LESSER_EQ(X1, X2) coda_oss::test::assert_lesser_eq(X1, X2, testName, __FILE__, SYS_FUNC, __LINE__)
#define TEST_ASSERT_LESSER(X1, X2) coda_oss::test::assert_lesser(X1, X2, testName, __FILE__, SYS_FUNC, __LINE__)
*/
#define TEST_FAIL(msg) coda_oss::test::fail(msg, testName, __FILE__, SYS_FUNC, __LINE__)
#define TEST_EXCEPTION(X) coda_oss::test::exception([&](){(X);}, testName, __FILE__, SYS_FUNC, __LINE__)
#define TEST_THROWS(X) coda_oss::test::throws([&](){(X);}, testName, __FILE__, SYS_FUNC, __LINE__)
# define TEST_SPECIFIC_EXCEPTION(X, Y) coda_oss::test::specific_exception<Y>([&](){(X);}, \
"%s (%s,%s,%d): FAILED: Should have thrown exception: " # Y , testName, __FILE__, SYS_FUNC, __LINE__)
# define TEST_CASE(X) void X(std::string testName)
#define TEST_MAIN(X) int main(int argc, char** argv) { return coda_oss::test::main(argc, argv, [&](){X;}); }
#define TEST_MAIN(X) int main(int argc, char** argv) { return coda_oss::test::main([&](){X;}); }
/*
# define TEST_CHECK(X) try{ X(std::string(#X)); std::cerr << #X << ": PASSED" << std::endl; } \
catch(const except::Throwable& ex) { die_printf("%s: FAILED: Exception thrown: %s\n", std::string(#X).c_str(), ex.toString().c_str()); } \
Expand All @@ -305,22 +311,27 @@ inline int main(int argc, char** argv, TFunc f)
# define TEST_ASSERT_NULL(X) if ((X) != nullptr) { die_printf("%s (%s,%s,%d): FAILED: Value should be NULL\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); }
# define TEST_ASSERT_FALSE(X) if ((X)) { die_printf("%s (%s,%s,%d): FAILED: Value should evaluate to false\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); }
# define TEST_ASSERT_TRUE(X) if (!(X)) { die_printf("%s (%s,%s,%d): FAILED: Value should evaluate to true\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); }
*/
# define TEST_ASSERT_EQ(X1, X2) if ((X1) != (X2)) { die_printf("%s (%s,%s,%d): FAILED: Recv'd %s, Expected %s\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__, str::toString(X1).c_str(), str::toString(X2).c_str()); }
# define TEST_ASSERT_EQ_MSG(msg, X1, X2) if ((X1) != (X2)) die_printf("%s (%s,%d): FAILED (%s): Recv'd %s, Expected %s\n", testName.c_str(), __FILE__, __LINE__, (msg).c_str(), str::toString((X1)).c_str(), str::toString((X2)).c_str());
# define TEST_ASSERT_NOT_EQ(X1, X2) if ((X1) == (X2)) { die_printf("%s (%s,%s,%d): FAILED: Recv'd %s should not equal %s\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__, str::toString(X1).c_str(), str::toString(X2).c_str()); }
# define TEST_ASSERT_NOT_EQ_MSG(msg, X1, X2) if ((X1) == (X2)) die_printf("%s (%s,%d): FAILED (%s): Recv'd %s should not equal %s\n", testName.c_str(), __FILE__, __LINE__, (msg).c_str(), str::toString((X1)).c_str(), str::toString((X2)).c_str());
/*
# define TEST_ASSERT_ALMOST_EQ_EPS(X1, X2, EPS) if (std::abs((X1) - (X2)) > EPS || IS_NAN(std::abs((X1) - (X2)))) die_printf("%s (%s,%d): FAILED: Recv'd %s, Expected %s\n", testName.c_str(), __FILE__, __LINE__, str::toString((X1)).c_str(), str::toString((X2)).c_str());
# define TEST_ASSERT_ALMOST_EQ(X1, X2) if (std::abs((X1) - (X2)) > std::numeric_limits<float>::epsilon() || IS_NAN(std::abs((X1) - (X2)))) { die_printf("%s (%s,%s,%d): FAILED: Recv'd %s, Expected %s\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__, str::toString(X1).c_str(), str::toString(X2).c_str()); }
*/
# define TEST_ASSERT_GREATER_EQ(X1, X2) if ((X1) < X2) { die_printf("%s (%s,%s,%d): FAILED: Value should be greater than or equal\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); }
# define TEST_ASSERT_GREATER(X1, X2) if ((X1) <= X2) { die_printf("%s (%s,%s,%d): FAILED: Value should be greater than\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); }
# define TEST_ASSERT_LESSER_EQ(X1, X2) if ((X1) > X2) { die_printf("%s (%s,%s,%d): FAILED: Value should be less than or equal\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); }
# define TEST_ASSERT_LESSER(X1, X2) if ((X1) >= X2) { die_printf("%s (%s,%s,%d): FAILED: Value should be less than\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); }
/*
# define TEST_FAIL(msg) die_printf("%s (%s,%s,%d): FAILED: %s\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__, str::toString(msg).c_str());
# define TEST_EXCEPTION(X) try{ (X); die_printf("%s (%s,%s,%d): FAILED: Should have thrown exception\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); } catch (const except::Throwable&){} catch (const except::Throwable11&){}
# define TEST_THROWS(X) try{ (X); die_printf("%s (%s,%s,%d): FAILED: Should have thrown exception\n", testName.c_str(), __FILE__, SYS_FUNC, __LINE__); } catch (...){}
# define TEST_SPECIFIC_EXCEPTION(X,Y) try{ (X); die_printf("%s (%s,%s,%d): FAILED: Should have thrown exception: " # Y , testName.c_str(), __FILE__, SYS_FUNC, __LINE__); } catch(const Y&) { } \
catch (const except::Throwable&){ die_printf("%s (%s,%s,%d): FAILED: Should have thrown exception: " # Y , testName.c_str(), __FILE__, SYS_FUNC, __LINE__);} \
catch (const except::Throwable11&){ die_printf("%s (%s,%s,%d): FAILED: Should have thrown exception: " # Y , testName.c_str(), __FILE__, SYS_FUNC, __LINE__);}
catch (const except::Throwable11&){ die_printf("%s (%s,%s,%d): FAILED: Should have thrown exception: " # Y , testName.c_str(), __FILE__, SYS_FUNC, __LINE__);} # define TEST_CASE(X) void X(std::string testName)
# define TEST_CASE(X) void X(std::string testName)
#define TEST_MAIN(X) int main(int argc, char** argv) { try { X; return EXIT_SUCCESS; } \
catch (const except::Exception& ex) { std::cerr << ex.toString() << std::endl; } \
catch (const std::exception& e) { std::cerr << e.what() << std::endl; } \
Expand Down

0 comments on commit 2323c32

Please sign in to comment.