1#!/usr/bin/env python3 2# Copyright 2016 Google Inc. All Rights Reserved. 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 16from absl.testing import parameterized 17from fruit_test_common import * 18 19COMMON_DEFINITIONS = ''' 20 #define IN_FRUIT_CPP_FILE 1 21 22 #include "meta/common.h" 23 #include <fruit/impl/meta/component.h> 24 25 struct A1 {}; 26 struct B1 {}; 27 28 using A = Type<A1>; 29 using B = Type<B1>; 30 ''' 31 32class TestMetaprogramming(parameterized.TestCase): 33 def test_GetNthType(self): 34 source = ''' 35 int main() { 36 AssertSameType(A, GetNthType(Int<0>, Vector<A>)); 37 38 AssertSameType(A, GetNthType(Int<0>, Vector<A, B>)); 39 AssertSameType(B, GetNthType(Int<1>, Vector<A, B>)); 40 } 41 ''' 42 expect_success( 43 COMMON_DEFINITIONS, 44 source, 45 locals()) 46 47if __name__ == '__main__': 48 absltest.main() 49