test08.cpp revision 12855:588919e0e4aa
1/***************************************************************************** 2 3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 4 more contributor license agreements. See the NOTICE file distributed 5 with this work for additional information regarding copyright ownership. 6 Accellera licenses this file to you under the Apache License, Version 2.0 7 (the "License"); you may not use this file except in compliance with the 8 License. You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, software 13 distributed under the License is distributed on an "AS IS" BASIS, 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 15 implied. See the License for the specific language governing 16 permissions and limitations under the License. 17 18 *****************************************************************************/ 19 20/***************************************************************************** 21 22 test08.cpp -- sc_vector of objects not derived from sc_object 23 (OSCI extension to IEEE 1666-2011) 24 25 Original Author: Philipp A. Hartmann, OFFIS, 2011-10-01 26 27 *****************************************************************************/ 28 29#include "systemc.h" 30 31struct foo 32{ 33 explicit 34 foo( const char* nm ) 35 : name(nm) 36 {} 37 std::string name; 38}; 39 40int sc_main( int, char*[] ) 41{ 42 sc_report_handler::set_actions( SC_ERROR, SC_DISPLAY ); 43 44 sc_vector< sc_event > ev_vec ( "evs", 1 ); 45 46 sc_assert( ev_vec.size() == 1 ); 47 // should print an error 48 sc_assert( ev_vec.get_elements().size() == 0 ); 49 50 sc_vector< foo > foo_vec( "foo", 1 ); 51 52 sc_assert( foo_vec.size() == 1 ); 53 sc_assert( sc_assemble_vector( foo_vec, &foo::name ).size() == 1 ); 54 // should print an error 55 sc_assert( sc_assemble_vector( foo_vec, &foo::name ) 56 .get_elements().size() == 0 ); 57 58 cout << "\nSuccess" << endl; 59 return 0; 60} 61