|
| 1 | +/*******************************************************************\ |
| 2 | +
|
| 3 | + Module: Unit tests for java_types |
| 4 | +
|
| 5 | + Author: Diffblue Ltd. |
| 6 | +
|
| 7 | +\*******************************************************************/ |
| 8 | + |
| 9 | +#include <testing-utils/catch.hpp> |
| 10 | +#include <java_bytecode/java_types.h> |
| 11 | + |
| 12 | +SCENARIO("java_type_from_string", "[core][java_types]") |
| 13 | +{ |
| 14 | + // TODO : add more cases, the current test is not comprehensive |
| 15 | + |
| 16 | + GIVEN("Ljava/lang/Integer;") |
| 17 | + { |
| 18 | + const auto integer_type = java_type_from_string("Ljava/lang/Integer;", ""); |
| 19 | + REQUIRE(integer_type != nil_typet()); |
| 20 | + } |
| 21 | + |
| 22 | + GIVEN("TE;") |
| 23 | + { |
| 24 | + const auto generic_type_E = java_type_from_string("TE;", "MyClass"); |
| 25 | + REQUIRE(generic_type_E != nil_typet()); |
| 26 | + } |
| 27 | + |
| 28 | + GIVEN("Ljava/util/List<TX;>;") |
| 29 | + { |
| 30 | + const auto generic_list_type = |
| 31 | + java_type_from_string("Ljava/util/List<TX;>;", "java.util.List"); |
| 32 | + REQUIRE(generic_list_type != nil_typet()); |
| 33 | + } |
| 34 | + |
| 35 | + GIVEN("Ljava/util/List<Ljava/lang/Integer>;") |
| 36 | + { |
| 37 | + const auto integer_list_type = |
| 38 | + java_type_from_string("Ljava/util/List<Ljava/lang/Integer;>;", ""); |
| 39 | + REQUIRE(integer_list_type != nil_typet()); |
| 40 | + } |
| 41 | + |
| 42 | + GIVEN("Ljava/util/Map<TK;TV;>;") |
| 43 | + { |
| 44 | + const auto generic_symbol_type = |
| 45 | + java_type_from_string("Ljava/util/Map<TK;TV;>;", "java.util.Map"); |
| 46 | + REQUIRE(generic_symbol_type != nil_typet()); |
| 47 | + } |
| 48 | +} |
0 commit comments