1*a65addddSAndroid Build Coastguard Worker#!/usr/bin/env python3 2*a65addddSAndroid Build Coastguard Worker# Copyright 2016 Google Inc. All Rights Reserved. 3*a65addddSAndroid Build Coastguard Worker# 4*a65addddSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 5*a65addddSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 6*a65addddSAndroid Build Coastguard Worker# You may obtain a copy of the License at 7*a65addddSAndroid Build Coastguard Worker# 8*a65addddSAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 9*a65addddSAndroid Build Coastguard Worker# 10*a65addddSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 11*a65addddSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS-IS" BASIS, 12*a65addddSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*a65addddSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 14*a65addddSAndroid Build Coastguard Worker# limitations under the License. 15*a65addddSAndroid Build Coastguard Worker 16*a65addddSAndroid Build Coastguard Workerfrom absl.testing import parameterized 17*a65addddSAndroid Build Coastguard Workerfrom fruit_test_common import * 18*a65addddSAndroid Build Coastguard Worker 19*a65addddSAndroid Build Coastguard WorkerCOMMON_DEFINITIONS = ''' 20*a65addddSAndroid Build Coastguard Worker #define IN_FRUIT_CPP_FILE 1 21*a65addddSAndroid Build Coastguard Worker 22*a65addddSAndroid Build Coastguard Worker #include "meta/common.h" 23*a65addddSAndroid Build Coastguard Worker #include <fruit/impl/meta/component.h> 24*a65addddSAndroid Build Coastguard Worker 25*a65addddSAndroid Build Coastguard Worker struct A1 {}; 26*a65addddSAndroid Build Coastguard Worker struct B1 {}; 27*a65addddSAndroid Build Coastguard Worker 28*a65addddSAndroid Build Coastguard Worker using A = Type<A1>; 29*a65addddSAndroid Build Coastguard Worker using B = Type<B1>; 30*a65addddSAndroid Build Coastguard Worker ''' 31*a65addddSAndroid Build Coastguard Worker 32*a65addddSAndroid Build Coastguard Workerclass TestMetaprogramming(parameterized.TestCase): 33*a65addddSAndroid Build Coastguard Worker def test_GetNthType(self): 34*a65addddSAndroid Build Coastguard Worker source = ''' 35*a65addddSAndroid Build Coastguard Worker int main() { 36*a65addddSAndroid Build Coastguard Worker AssertSameType(A, GetNthType(Int<0>, Vector<A>)); 37*a65addddSAndroid Build Coastguard Worker 38*a65addddSAndroid Build Coastguard Worker AssertSameType(A, GetNthType(Int<0>, Vector<A, B>)); 39*a65addddSAndroid Build Coastguard Worker AssertSameType(B, GetNthType(Int<1>, Vector<A, B>)); 40*a65addddSAndroid Build Coastguard Worker } 41*a65addddSAndroid Build Coastguard Worker ''' 42*a65addddSAndroid Build Coastguard Worker expect_success( 43*a65addddSAndroid Build Coastguard Worker COMMON_DEFINITIONS, 44*a65addddSAndroid Build Coastguard Worker source, 45*a65addddSAndroid Build Coastguard Worker locals()) 46*a65addddSAndroid Build Coastguard Worker 47*a65addddSAndroid Build Coastguard Workerif __name__ == '__main__': 48*a65addddSAndroid Build Coastguard Worker absltest.main() 49