|
| 1 | +/*******************************************************************\ |
| 2 | +
|
| 3 | + Module: Unit tests for converting fields |
| 4 | +
|
| 5 | + Author: Diffblue Ltd. |
| 6 | +
|
| 7 | +\*******************************************************************/ |
| 8 | + |
| 9 | +#include <java-testing-utils/load_java_class.h> |
| 10 | +#include <java_bytecode/java_bytecode_convert_class.h> |
| 11 | +#include <java_bytecode/java_bytecode_parse_tree.h> |
| 12 | +#include <java_bytecode/java_types.h> |
| 13 | +#include <testing-utils/catch.hpp> |
| 14 | + |
| 15 | +SCENARIO( |
| 16 | + "java_bytecode_parse_field", |
| 17 | + "[core][java_bytecode][java_bytecode_parser]") |
| 18 | +{ |
| 19 | + GIVEN("Some class with final and non final fields") |
| 20 | + { |
| 21 | + const symbol_tablet &symbol_table = load_java_class( |
| 22 | + "ClassWithFields", "./java_bytecode/java_bytecode_parser"); |
| 23 | + |
| 24 | + WHEN("Parsing the class file structure") |
| 25 | + { |
| 26 | + THEN("The the final status of the classes fields should be correct.") |
| 27 | + { |
| 28 | + const symbolt &class_symbol = |
| 29 | + symbol_table.lookup_ref("java::ClassWithFields"); |
| 30 | + const java_class_typet &java_class = |
| 31 | + to_java_class_type(class_symbol.type); |
| 32 | + REQUIRE(java_class.get_component("final1").get_is_final()); |
| 33 | + REQUIRE(java_class.get_component("final2").get_is_final()); |
| 34 | + REQUIRE(java_class.get_component("final3").get_is_final()); |
| 35 | + REQUIRE(!java_class.get_component("nonFinal1").get_is_final()); |
| 36 | + REQUIRE(!java_class.get_component("nonFinal1").get_is_final()); |
| 37 | + REQUIRE(!java_class.get_component("nonFinal1").get_is_final()); |
| 38 | + } |
| 39 | + } |
| 40 | + } |
| 41 | +} |
0 commit comments