Home | History | Annotate | Download | only in types
      1 /*
      2  * Copyright (C) 2013 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #include "common_test.h"
     18 #include "sea_ir/types/types.h"
     19 
     20 namespace sea_ir {
     21 
     22 class TypeDataTest : public art::CommonTest {
     23 };
     24 
     25 TEST_F(TypeDataTest, Basics) {
     26   TypeData td;
     27   art::verifier::RegTypeCache type_cache(false);
     28   int first_instruction_id = 1;
     29   int second_instruction_id = 3;
     30   EXPECT_TRUE(NULL == td.FindTypeOf(first_instruction_id));
     31   const Type* int_type = &type_cache.Integer();
     32   const Type* byte_type = &type_cache.Byte();
     33   td.SetTypeOf(first_instruction_id, int_type);
     34   EXPECT_TRUE(int_type == td.FindTypeOf(first_instruction_id));
     35   EXPECT_TRUE(NULL == td.FindTypeOf(second_instruction_id));
     36   td.SetTypeOf(second_instruction_id, byte_type);
     37   EXPECT_TRUE(int_type == td.FindTypeOf(first_instruction_id));
     38   EXPECT_TRUE(byte_type == td.FindTypeOf(second_instruction_id));
     39 }
     40 
     41 }  // namespace sea_ir
     42