-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb30ec2
commit c286b78
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/*******************************************************************\ | ||
Module: Unit tests for java_types | ||
Author: Diffblue Ltd. | ||
\*******************************************************************/ | ||
|
||
#include <testing-utils/catch.hpp> | ||
#include <java_types.h> | ||
|
||
SCENARIO("generic_type_index", "[core][java_types]") | ||
{ | ||
// Arrange | ||
const auto symbol_type = symbol_typet("MyType"); | ||
const auto generic_symbol_type = java_generic_symbol_typet( | ||
symbol_type, "LGenericClass<TX;TY;>;", "PrefixClassName"); | ||
java_generic_parametert paramX("PrefixClassName::X", symbol_typet()); | ||
java_generic_parametert paramY("PrefixClassName::Y", symbol_typet()); | ||
java_generic_parametert paramZ("PrefixClassName::Z", symbol_typet()); | ||
|
||
// Act | ||
const auto indexX = generic_symbol_type.generic_type_index(paramX); | ||
const auto indexY = generic_symbol_type.generic_type_index(paramY); | ||
const auto indexZ = generic_symbol_type.generic_type_index(paramZ); | ||
|
||
// Assert | ||
REQUIRE(indexX.has_value()); | ||
REQUIRE(indexX.value() == 0); | ||
REQUIRE(indexY.has_value()); | ||
REQUIRE(indexY.value() == 1); | ||
REQUIRE(!indexZ.has_value()); | ||
} |