| 27 | #include <geode/tests/common.hpp> |
| 28 | |
| 29 | void test_bijective_mappings() |
| 30 | { |
| 31 | geode::BijectiveMapping< geode::index_t, double > bijective; |
| 32 | bijective.map( 0, 42.1 ); |
| 33 | bijective.clear(); |
| 34 | bijective.map( 0, 42.1 ); |
| 35 | geode::OpenGeodeBasicException::test( bijective.has_mapping_input( 0 ), |
| 36 | "0 should be a key for bijective inputs" ); |
| 37 | geode::OpenGeodeBasicException::test( bijective.has_mapping_output( 42.1 ), |
| 38 | "42.1 should be a key for bijective outputs" ); |
| 39 | bijective.map( 1, -22 ); |
| 40 | geode::OpenGeodeBasicException::test( bijective.has_mapping_input( 1 ), |
| 41 | "1 should be a key for bijective inputs" ); |
| 42 | geode::OpenGeodeBasicException::test( bijective.has_mapping_output( -22 ), |
| 43 | "-22 should be a key for bijective outputs" ); |
| 44 | geode::OpenGeodeBasicException::test( |
| 45 | bijective.size() == 2, "Size of bijective should be 2" ); |
| 46 | bijective.map( 3, -22 ); |
| 47 | geode::OpenGeodeBasicException::test( |
| 48 | bijective.size() == 2, "Size of bijective should still be 2" ); |
| 49 | geode::OpenGeodeBasicException::test( bijective.has_mapping_input( 3 ), |
| 50 | "3 should be a key for bijective inputs" ); |
| 51 | geode::OpenGeodeBasicException::test( !bijective.has_mapping_input( 1 ), |
| 52 | "1 should not be a key for bijective inputs anymore" ); |
| 53 | bijective.erase_out( 42.1 ); |
| 54 | geode::OpenGeodeBasicException::test( !bijective.has_mapping_output( 42.1 ), |
| 55 | "42.1 should not be a key for bijective outputs anymore" ); |
| 56 | geode::OpenGeodeBasicException::test( !bijective.has_mapping_input( 0 ), |
| 57 | "0 should not be a key for bijective inputs anymore" ); |
| 58 | geode::OpenGeodeBasicException::test( |
| 59 | bijective.size() == 1, "Size of bijective should be 1" ); |
| 60 | bijective.map( 3, 11.1 ); |
| 61 | geode::OpenGeodeBasicException::test( |
| 62 | bijective.size() == 1, "Size of bijective should still be 1" ); |
| 63 | geode::OpenGeodeBasicException::test( bijective.has_mapping_output( 11.1 ), |
| 64 | "11.1 should be a key for bijective outputs" ); |
| 65 | geode::OpenGeodeBasicException::test( !bijective.has_mapping_output( -22 ), |
| 66 | "-22 should not be a key for bijective outputs anymore" ); |
| 67 | } |
| 68 | |
| 69 | void test_generic_mappings() |
| 70 | { |
no test coverage detected