< prev index next >

test/hotspot/gtest/oops/test_instanceKlass.cpp

Print this page
rev 58452 : imported patch pkg_name_from_class

*** 27,40 **** #include "memory/resourceArea.hpp" #include "oops/instanceKlass.hpp" #include "unittest.hpp" // Tests InstanceKlass::package_from_name() ! TEST_VM(InstanceKlass, null_symbol) { ! ResourceMark rm; ! TempNewSymbol package_sym = InstanceKlass::package_from_name(NULL, NULL); ! ASSERT_TRUE(package_sym == NULL) << "Wrong package for NULL symbol"; } // Tests for InstanceKlass::is_class_loader_instance_klass() function TEST_VM(InstanceKlass, class_loader_class) { InstanceKlass* klass = SystemDictionary::ClassLoader_klass(); --- 27,104 ---- #include "memory/resourceArea.hpp" #include "oops/instanceKlass.hpp" #include "unittest.hpp" // Tests InstanceKlass::package_from_name() ! TEST_VM(InstanceKlass, null_class_name) { ! bool bad_class_name = false; ! TempNewSymbol retval = InstanceKlass::package_from_name(NULL, &bad_class_name); ! ASSERT_TRUE(bad_class_name) << "Function did not set bad_class_name with NULL class name"; ! ASSERT_TRUE(retval == NULL) << "Wrong package for NULL class name pointer"; ! } ! ! TEST_VM(InstanceKlass, empty_class_name) { ! bool bad_class_name = false; ! TempNewSymbol name = SymbolTable::new_symbol(""); ! TempNewSymbol retval = InstanceKlass::package_from_name(name, &bad_class_name); ! ASSERT_TRUE(retval == NULL) << "Wrong package for empty string"; ! } ! ! TEST_VM(InstanceKlass, no_slash) { ! bool bad_class_name = false; ! TempNewSymbol name = SymbolTable::new_symbol("L"); ! TempNewSymbol retval = InstanceKlass::package_from_name(name, &bad_class_name); ! ASSERT_FALSE(bad_class_name) << "Function set bad_class_name with empty package"; ! ASSERT_TRUE(retval == NULL) << "Wrong package for class with no slashes"; ! } ! ! TEST_VM(InstanceKlass, just_slash) { ! bool bad_class_name = false; ! TempNewSymbol name = SymbolTable::new_symbol("/"); ! TempNewSymbol retval = InstanceKlass::package_from_name(name, &bad_class_name); ! ASSERT_TRUE(bad_class_name) << "Function did not set bad_class_name with package of length 0"; ! ASSERT_TRUE(retval == NULL) << "Wrong package for class with just slash"; ! } ! ! TEST_VM(InstanceKlass, multiple_slashes) { ! bool bad_class_name = false; ! TempNewSymbol name = SymbolTable::new_symbol("///"); ! TempNewSymbol retval = InstanceKlass::package_from_name(name, &bad_class_name); ! ASSERT_FALSE(bad_class_name) << "Function set bad_class_name with slashes package"; ! ASSERT_TRUE(retval->equals("//")) << "Wrong package for class with just slashes"; ! } ! ! TEST_VM(InstanceKlass, standard_case_1) { ! bool bad_class_name = false; ! TempNewSymbol name = SymbolTable::new_symbol("package/class"); ! TempNewSymbol retval = InstanceKlass::package_from_name(name, &bad_class_name); ! ASSERT_FALSE(bad_class_name) << "Function set bad_class_name for valid package"; ! ASSERT_TRUE(retval->equals("package")) << "Wrong package for class with one slash"; ! } ! ! TEST_VM(InstanceKlass, standard_case_2) { ! bool bad_class_name = false; ! TempNewSymbol name = SymbolTable::new_symbol("package/folder/class"); ! TempNewSymbol retval = InstanceKlass::package_from_name(name, &bad_class_name); ! ASSERT_FALSE(bad_class_name) << "Function set bad_class_name for valid package"; ! ASSERT_TRUE(retval->equals("package/folder")) << "Wrong package for class with multiple slashes"; ! } ! ! TEST_VM(InstanceKlass, class_array) { ! bool bad_class_name = false; ! TempNewSymbol name = SymbolTable::new_symbol("[package/class"); ! TempNewSymbol retval = InstanceKlass::package_from_name(name, &bad_class_name); ! ASSERT_FALSE(bad_class_name) << "Function set bad_class_name with class array"; ! ASSERT_TRUE(retval->equals("package")) << "Wrong package for class with leading bracket"; ! } ! ! TEST_VM(InstanceKlass, class_object_array) { ! bool bad_class_name = false; ! TempNewSymbol name = SymbolTable::new_symbol("[Lpackage/class"); ! TempNewSymbol retval = InstanceKlass::package_from_name(name, &bad_class_name); ! ASSERT_TRUE(bad_class_name) << "Function did not set bad_class_name with array of class objects"; ! ASSERT_TRUE(retval == NULL) << "Wrong package for class with leading '[L'"; } // Tests for InstanceKlass::is_class_loader_instance_klass() function TEST_VM(InstanceKlass, class_loader_class) { InstanceKlass* klass = SystemDictionary::ClassLoader_klass();
< prev index next >