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 fruit_test_common import * 17 18COMMON_DEFINITIONS = ''' 19 #define IN_FRUIT_CPP_FILE 1 20 21 #include "meta/common.h" 22 #include <fruit/impl/meta/component.h> 23 24 struct A1 {}; 25 struct B1 {}; 26 27 using A = Type<A1>; 28 using B = Type<B1>; 29 ''' 30 31def test_GetNthType(): 32 source = ''' 33 int main() { 34 AssertSameType(A, GetNthType(Int<0>, Vector<A>)); 35 36 AssertSameType(A, GetNthType(Int<0>, Vector<A, B>)); 37 AssertSameType(B, GetNthType(Int<1>, Vector<A, B>)); 38 } 39 ''' 40 expect_success( 41 COMMON_DEFINITIONS, 42 source, 43 locals()) 44 45if __name__== '__main__': 46 main(__file__) 47