| 1 |
/*************************************************************************************** |
| 2 |
* This file is dedicated to the public domain. If your jurisdiction requires a * |
| 3 |
* specific license: * |
| 4 |
* * |
| 5 |
* Copyright (c) Stephen McDowell, 2017-2024 * |
| 6 |
* License: CC0 1.0 Universal * |
| 7 |
* License Text: https://creativecommons.org/publicdomain/zero/1.0/legalcode * |
| 8 |
**************************************************************************************/ |
| 9 |
#include <catch2/catch.hpp> |
| 10 |
#include <type_traits> |
| 11 |
#include <sstream> |
| 12 |
|
| 13 |
#include <absurdly_long_names.hpp> |
| 14 |
|
| 15 |
TEST_CASE( "MAKE_IT_BIG(class)", "[cpp-long-names]" ) { |
| 16 |
MAKE_IT_BIG(class) cls; |
| 17 |
int value = cls.value; |
| 18 |
REQUIRE( value == 1 ); |
| 19 |
} |
| 20 |
|
| 21 |
TEST_CASE( "MAKE_IT_BIG(struct)", "[cpp-long-names]" ) { |
| 22 |
MAKE_IT_BIG(struct) s; |
| 23 |
int value = s.value; |
| 24 |
REQUIRE( value == 2 ); |
| 25 |
} |
| 26 |
|
| 27 |
TEST_CASE( "MAKE_IT_BIG(function)", "[cpp-long-names]" ) { |
| 28 |
auto divergence = MAKE_IT_BIG(function)(); |
| 29 |
REQUIRE( divergence == "The divergence number: 0.999999999" ); |
| 30 |
} |
| 31 |
|
| 32 |
TEST_CASE( "MAKE_IT_BIG(enum)", "[cpp-long-names]" ) { |
| 33 |
REQUIRE( MAKE_IT_BIG(enum)::first == 1 ); |
| 34 |
REQUIRE( MAKE_IT_BIG(enum)::second == 2 ); |
| 35 |
REQUIRE( MAKE_IT_BIG(enum)::third == 3 ); |
| 36 |
} |
| 37 |
|
| 38 |
TEST_CASE( "MAKE_IT_BIG(namespace)", "[cpp-long-names]" ) { |
| 39 |
int value = MAKE_IT_BIG(namespace)::value; |
| 40 |
REQUIRE( value == 0 ); |
| 41 |
} |
| 42 |
|
| 43 |
TEST_CASE( "#define longer than 255", "[cpp-long-names]" ) { |
| 44 |
auto Jajajaja = std::string(DEFINE_THAT_IS_LONGER_THAN_TWO_HUNDRED_AND_FIFTY_FIVE_CHARACTERS_LONG_WHICH_IS_AN_ABSOLUTELY_AND_COMPLETELY_RIDICULOUS_THING_TO_DO_AND_IF_YOU_DID_THIS_IN_THE_REAL_WORLD_YOU_PUT_YOURSELF_COMFORTABLY_IN_A_POSITION_TO_BE_DOWNSIZED_AND_OUTTA_HERE_AS_SOUL_POSITION_WOULD_EXPLAIN_TO_YOU); |
| 45 |
REQUIRE( Jajajaja == "Jajajaja" ); |
| 46 |
} |
| 47 |
|
| 48 |
TEST_CASE( "MAKE_IT_BIG(variable)", "[cpp-long-names]" ) { |
| 49 |
int var = MAKE_IT_BIG(variable); |
| 50 |
REQUIRE( var == 929 ); |
| 51 |
} |
| 52 |
|
| 53 |
TEST_CASE( "MAKE_IT_BIG(typedef)", "[cpp-long-names]" ) { |
| 54 |
// sigh, std::is_same_v introduced in C++17, i'm compiling in C++14. |
| 55 |
bool is_float = std::is_same<MAKE_IT_BIG(typedef), float>::value; |
| 56 |
REQUIRE( is_float ); |
| 57 |
} |
| 58 |
|
| 59 |
TEST_CASE( "MAKE_IT_BIG(union)", "[cpp-long-names]" ) { |
| 60 |
// from the docs: https://en.cppreference.com/w/cpp/language/union |
| 61 |
MAKE_IT_BIG(union) u = {0x12345678}; // initializes the first member, s.n is now the active member |
| 62 |
std::ostringstream n_stream; |
| 63 |
n_stream << std::hex << "u.n = 0x" << u.n; |
| 64 |
std::string n_str = n_stream.str(); |
| 65 |
REQUIRE( n_str == "u.n = 0x12345678" ); |
| 66 |
} |
| 67 |
|
| 68 |
#if !defined(_WIN32) |
| 69 |
#include <directory/structure/that/is/longer/than/two/hundred/and/fifty/five/characters/long/which/is/an/absolutely/and/completely/ridiculous/thing/to/do/and/if/you/did/this/in/the/real/world/you/put/yourself/comfortably/in/a/position/to/be/downsized/and/outta/here/as/soul/position/would/explain/to/you/a_file.hpp> |
| 70 |
TEST_CASE( "absurd directory structure", "[cpp-long-names]" ) { |
| 71 |
auto nested = extremely_nested(); |
| 72 |
REQUIRE( nested == "Extremely nested works!!!" ); |
| 73 |
} |
| 74 |
#endif |