Skip to content

Commit

Permalink
Unit test for generic_type_index
Browse files Browse the repository at this point in the history
  • Loading branch information
romainbrenguier committed May 2, 2018
1 parent a647f41 commit d86e8e4
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions unit/java_bytecode/java_types/generic_type_index.cpp
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());
}

0 comments on commit d86e8e4

Please sign in to comment.