diff --git a/CMakeTestFiles/TestICGLinkedLibs.cpp b/CMakeTestFiles/TestICGLinkedLibs.cpp index 33ce68915..ebd5928db 100644 --- a/CMakeTestFiles/TestICGLinkedLibs.cpp +++ b/CMakeTestFiles/TestICGLinkedLibs.cpp @@ -1,22 +1,22 @@ -// `llvm/Support/Host.h` is deprecated in favour of `llvm/TargetParser/Host.h` since clang 17 -#if LIBCLANG_MAJOR > 16 -#include "llvm/TargetParser/Host.h" +// `llvm/Support/Host.h` is deprecated in favour of `llvm/TargetParser/Host.h` since clang 17 +#if LIBCLANG_MAJOR > 16 +#include "llvm/TargetParser/Host.h" #else -#include "llvm/Support/Host.h" +#include "llvm/Support/Host.h" #endif -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/raw_ostream.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/raw_ostream.h" -#include "clang/Basic/Builtins.h" -#include "clang/Frontend/CompilerInstance.h" -#include "clang/Basic/TargetOptions.h" -#include "clang/Basic/TargetInfo.h" -#include "clang/Basic/FileManager.h" -#include "clang/Lex/Preprocessor.h" -#include "clang/Lex/PreprocessorOptions.h" -#include "clang/Basic/Diagnostic.h" -#include "clang/Parse/ParseAST.h" +#include "clang/Basic/Builtins.h" +#include "clang/Frontend/CompilerInstance.h" +#include "clang/Basic/TargetOptions.h" +#include "clang/Basic/TargetInfo.h" +#include "clang/Basic/FileManager.h" +#include "clang/Lex/Preprocessor.h" +#include "clang/Lex/PreprocessorOptions.h" +#include "clang/Basic/Diagnostic.h" +#include "clang/Parse/ParseAST.h" -int main() { - return 0; +int main() { + return 0; } \ No newline at end of file diff --git a/test/SIM_anon_enum/models/starter.cpp b/test/SIM_anon_enum/models/starter.cpp index 60da96a38..fcbb9187a 100644 --- a/test/SIM_anon_enum/models/starter.cpp +++ b/test/SIM_anon_enum/models/starter.cpp @@ -1,5 +1,5 @@ -#include "starter.h" +#include "starter.h" -Starter::Starter() { +Starter::Starter() { } diff --git a/test/SIM_checkpoint_data_recording/models/Foo.cpp b/test/SIM_checkpoint_data_recording/models/Foo.cpp index 53e0e3f85..638e6c4bd 100644 --- a/test/SIM_checkpoint_data_recording/models/Foo.cpp +++ b/test/SIM_checkpoint_data_recording/models/Foo.cpp @@ -1 +1 @@ -#include "Foo.hh" +#include "Foo.hh" diff --git a/test/SIM_delete_default_constructor/models/empty.cpp b/test/SIM_delete_default_constructor/models/empty.cpp index 6d9fb2d39..fe0e6d3dc 100644 --- a/test/SIM_delete_default_constructor/models/empty.cpp +++ b/test/SIM_delete_default_constructor/models/empty.cpp @@ -1 +1 @@ -#include "empty.h" +#include "empty.h" diff --git a/test/SIM_delete_default_constructor/models/starter.cpp b/test/SIM_delete_default_constructor/models/starter.cpp index b8761d13d..ccc6ccf62 100644 --- a/test/SIM_delete_default_constructor/models/starter.cpp +++ b/test/SIM_delete_default_constructor/models/starter.cpp @@ -1,6 +1,6 @@ -#include "starter.h" +#include "starter.h" -Starter::Starter(int foo) { - +Starter::Starter(int foo) { + } diff --git a/test/SIM_demo_inputfile/models/InputProcessSimObject/src/InputProcessSimObject.cpp b/test/SIM_demo_inputfile/models/InputProcessSimObject/src/InputProcessSimObject.cpp index 44ac37f63..d6c94ca6c 100644 --- a/test/SIM_demo_inputfile/models/InputProcessSimObject/src/InputProcessSimObject.cpp +++ b/test/SIM_demo_inputfile/models/InputProcessSimObject/src/InputProcessSimObject.cpp @@ -1,32 +1,32 @@ -#ifndef TRICK_ICG -#include +#ifndef TRICK_ICG +#include #endif -#include -#include +#include +#include -#include "InputProcessSimObject/include/InputProcessSimObject.hh" +#include "InputProcessSimObject/include/InputProcessSimObject.hh" -Trick::InputProcessSimObject::InputProcessSimObject(std::string in_function) { +Trick::InputProcessSimObject::InputProcessSimObject(std::string in_function) { - python_call_function = in_function ; - return_value = 0 ; + python_call_function = in_function ; + return_value = 0 ; } -int Trick::InputProcessSimObject::call_function( Trick::JobData * curr_job ) { +int Trick::InputProcessSimObject::call_function( Trick::JobData * curr_job ) { - std::stringstream ss ; + std::stringstream ss ; - ss << python_call_function << "(" << curr_job->id << ")" ; - PyRun_SimpleString(ss.str().c_str()) ; + ss << python_call_function << "(" << curr_job->id << ")" ; + PyRun_SimpleString(ss.str().c_str()) ; - return( return_value ) ; + return( return_value ) ; } -double Trick::InputProcessSimObject::call_function_double( Trick::JobData * curr_job ) { +double Trick::InputProcessSimObject::call_function_double( Trick::JobData * curr_job ) { - (void)curr_job ; - return(0.0) ; + (void)curr_job ; + return(0.0) ; } diff --git a/test/SIM_exclusion_mechanisms/models/ExtLibDir.cpp b/test/SIM_exclusion_mechanisms/models/ExtLibDir.cpp index 02086a788..dae2c0b49 100644 --- a/test/SIM_exclusion_mechanisms/models/ExtLibDir.cpp +++ b/test/SIM_exclusion_mechanisms/models/ExtLibDir.cpp @@ -1 +1 @@ -This file should be excluded from the build. Is is meant to cause a compiler error if Trick tries to build it. +This file should be excluded from the build. Is is meant to cause a compiler error if Trick tries to build it. diff --git a/test/SIM_exclusion_mechanisms/models/Foo.cpp b/test/SIM_exclusion_mechanisms/models/Foo.cpp index 222ffaa3f..29218f4c3 100644 --- a/test/SIM_exclusion_mechanisms/models/Foo.cpp +++ b/test/SIM_exclusion_mechanisms/models/Foo.cpp @@ -1,2 +1,2 @@ -// @trick_link_dependency{ExtLibDir.cpp} -// @trick_link_dependency{ext_lib_dir/ExtLibDir.cpp} +// @trick_link_dependency{ExtLibDir.cpp} +// @trick_link_dependency{ext_lib_dir/ExtLibDir.cpp} diff --git a/test/SIM_exclusion_mechanisms/models/ext_lib_dir/ExtLibDir.cpp b/test/SIM_exclusion_mechanisms/models/ext_lib_dir/ExtLibDir.cpp index 02086a788..dae2c0b49 100644 --- a/test/SIM_exclusion_mechanisms/models/ext_lib_dir/ExtLibDir.cpp +++ b/test/SIM_exclusion_mechanisms/models/ext_lib_dir/ExtLibDir.cpp @@ -1 +1 @@ -This file should be excluded from the build. Is is meant to cause a compiler error if Trick tries to build it. +This file should be excluded from the build. Is is meant to cause a compiler error if Trick tries to build it. diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/real/ext_lib_dir/ExtLibDir.cpp b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/real/ext_lib_dir/ExtLibDir.cpp index 02086a788..dae2c0b49 100644 --- a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/real/ext_lib_dir/ExtLibDir.cpp +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_link_path/real/ext_lib_dir/ExtLibDir.cpp @@ -1 +1 @@ -This file should be excluded from the build. Is is meant to cause a compiler error if Trick tries to build it. +This file should be excluded from the build. Is is meant to cause a compiler error if Trick tries to build it. diff --git a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/real/ext_lib_dir/ExtLibDir.cpp b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/real/ext_lib_dir/ExtLibDir.cpp index 02086a788..dae2c0b49 100644 --- a/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/real/ext_lib_dir/ExtLibDir.cpp +++ b/test/SIM_exclusion_mechanisms/models/symlinks/exclude_real_path/real/ext_lib_dir/ExtLibDir.cpp @@ -1 +1 @@ -This file should be excluded from the build. Is is meant to cause a compiler error if Trick tries to build it. +This file should be excluded from the build. Is is meant to cause a compiler error if Trick tries to build it. diff --git a/test/SIM_exec_set_time_tic_value/models/ttvtest.cpp b/test/SIM_exec_set_time_tic_value/models/ttvtest.cpp index cf516ba24..3d6d4b83f 100644 --- a/test/SIM_exec_set_time_tic_value/models/ttvtest.cpp +++ b/test/SIM_exec_set_time_tic_value/models/ttvtest.cpp @@ -1,21 +1,21 @@ -#include -#include "ttvtest.h" -int TTVTest::scheduled() { - //message_publish(MSG_NORMAL, "Hello World!\n"); - return 0; +#include +#include "ttvtest.h" +int TTVTest::scheduled() { + //message_publish(MSG_NORMAL, "Hello World!\n"); + return 0; } -int TTVTest::scheduled2() { - //message_publish(MSG_NORMAL, "Hello World!\n"); - return 0; +int TTVTest::scheduled2() { + //message_publish(MSG_NORMAL, "Hello World!\n"); + return 0; } -int TTVTest::scheduled3() { - //message_publish(MSG_NORMAL, "Hello World!\n"); - return 0; +int TTVTest::scheduled3() { + //message_publish(MSG_NORMAL, "Hello World!\n"); + return 0; } -int TTVTest::scheduled4() { - //message_publish(MSG_NORMAL, "Hello World!\n"); - return 0; +int TTVTest::scheduled4() { + //message_publish(MSG_NORMAL, "Hello World!\n"); + return 0; } \ No newline at end of file diff --git a/test/SIM_isystem/models/my_code/Foo.cpp b/test/SIM_isystem/models/my_code/Foo.cpp index c70664dbe..e75fdb5e3 100644 --- a/test/SIM_isystem/models/my_code/Foo.cpp +++ b/test/SIM_isystem/models/my_code/Foo.cpp @@ -1,3 +1,3 @@ -// @trick_link_dependency{Warning.cpp} +// @trick_link_dependency{Warning.cpp} -#include "Warning.hh" +#include "Warning.hh" diff --git a/test/SIM_isystem/models/third_party/Warning.cpp b/test/SIM_isystem/models/third_party/Warning.cpp index 87a489338..f865cff91 100644 --- a/test/SIM_isystem/models/third_party/Warning.cpp +++ b/test/SIM_isystem/models/third_party/Warning.cpp @@ -1 +1 @@ -#include +#include diff --git a/test/SIM_job_class_order/models/starter.cpp b/test/SIM_job_class_order/models/starter.cpp index ff7b51cb1..1d6a7f64f 100644 --- a/test/SIM_job_class_order/models/starter.cpp +++ b/test/SIM_job_class_order/models/starter.cpp @@ -1,76 +1,76 @@ -#include "starter.h" -#include -#include "trick/exec_proto.hh" -#include "trick/exec_proto.h" +#include "starter.h" +#include +#include "trick/exec_proto.hh" +#include "trick/exec_proto.h" -void Starter::sched () { - sched_calls++; +void Starter::sched () { + sched_calls++; } -void Starter::custom () { - custom_calls++; +void Starter::custom () { + custom_calls++; } -void Starter::top () { - top_calls++; +void Starter::top () { + top_calls++; } -void Starter::automatic () { +void Starter::automatic () { - Trick::JobData * thisJob = exec_get_curr_job() ; - thisJob->set_next_call_time(exec_get_time_tics() + exec_get_time_tic_value()); - automatic_calls++; + Trick::JobData * thisJob = exec_get_curr_job() ; + thisJob->set_next_call_time(exec_get_time_tics() + exec_get_time_tic_value()); + automatic_calls++; } -void Starter::automatic_last () { +void Starter::automatic_last () { - Trick::JobData * thisJob = exec_get_curr_job() ; - thisJob->set_next_call_time(exec_get_time_tics() + exec_get_time_tic_value()); + Trick::JobData * thisJob = exec_get_curr_job() ; + thisJob->set_next_call_time(exec_get_time_tics() + exec_get_time_tic_value()); - automatic_last_calls++; + automatic_last_calls++; } -void Starter::end() { - end_calls++; +void Starter::end() { + end_calls++; } -void Starter::deriv() { - deriv_calls++; +void Starter::deriv() { + deriv_calls++; } -int Starter::integ() { - integ_calls++; +int Starter::integ() { + integ_calls++; - return 0; + return 0; } -void Starter::test_calls() { - if (top_calls == 0) { - exec_terminate_with_return(1, __FILE__, __LINE__, "top_of_frame job never called"); - } +void Starter::test_calls() { + if (top_calls == 0) { + exec_terminate_with_return(1, __FILE__, __LINE__, "top_of_frame job never called"); + } - if (custom_calls == 0) { - exec_terminate_with_return(1, __FILE__, __LINE__, "custom job never called"); - } + if (custom_calls == 0) { + exec_terminate_with_return(1, __FILE__, __LINE__, "custom job never called"); + } - if (sched_calls == 0) { - exec_terminate_with_return(1, __FILE__, __LINE__, "scheduled job never called"); - } + if (sched_calls == 0) { + exec_terminate_with_return(1, __FILE__, __LINE__, "scheduled job never called"); + } - if (automatic_calls == 0) { - exec_terminate_with_return(1, __FILE__, __LINE__, "automatic job never called"); - } + if (automatic_calls == 0) { + exec_terminate_with_return(1, __FILE__, __LINE__, "automatic job never called"); + } - if (automatic_last_calls == 0) { - exec_terminate_with_return(1, __FILE__, __LINE__, "automatic_last job never called"); - } + if (automatic_last_calls == 0) { + exec_terminate_with_return(1, __FILE__, __LINE__, "automatic_last job never called"); + } - if (deriv_calls == 0) { - exec_terminate_with_return(1, __FILE__, __LINE__, "derivative job never called"); - } + if (deriv_calls == 0) { + exec_terminate_with_return(1, __FILE__, __LINE__, "derivative job never called"); + } - if (integ_calls == 0) { - exec_terminate_with_return(1, __FILE__, __LINE__, "integration job never called"); - } + if (integ_calls == 0) { + exec_terminate_with_return(1, __FILE__, __LINE__, "integration job never called"); + } } diff --git a/test/SIM_leaks/models/Leaker/Leaker.cpp b/test/SIM_leaks/models/Leaker/Leaker.cpp index 0308e7e4e..b8c65fbcb 100644 --- a/test/SIM_leaks/models/Leaker/Leaker.cpp +++ b/test/SIM_leaks/models/Leaker/Leaker.cpp @@ -1,37 +1,37 @@ -#include -#include -#include +#include +#include +#include -/* Model include files. */ -#include "sim_services/MemoryManager/include/memorymanager_c_intf.h" +/* Model include files. */ +#include "sim_services/MemoryManager/include/memorymanager_c_intf.h" -std::vector< int > dv ; +std::vector< int > dv ; - /* ENTRY POINT */ -int Leaker() { + /* ENTRY POINT */ +int Leaker() { - int * i_malloc = (int *)malloc( sizeof(int) ) ; + int * i_malloc = (int *)malloc( sizeof(int) ) ; - int * i_calloc = (int *)calloc( 1 , sizeof(int) ) ; + int * i_calloc = (int *)calloc( 1 , sizeof(int) ) ; -#if 0 - int * i_realloc = NULL ; - i_realloc = (int *)realloc( i_realloc, sizeof(int) ) ; +#if 0 + int * i_realloc = NULL ; + i_realloc = (int *)realloc( i_realloc, sizeof(int) ) ; #endif - int * i_new = new int ; + int * i_new = new int ; - int * ia_new = new int[10] ; + int * ia_new = new int[10] ; - char * str = strdup("hello") ; + char * str = strdup("hello") ; - int ii ; - for ( ii = 0 ; ii < 100 ; ii++ ) { - dv.push_back(ii) ; - } + int ii ; + for ( ii = 0 ; ii < 100 ; ii++ ) { + dv.push_back(ii) ; + } - /* RETURN */ - return( 0 ); + /* RETURN */ + return( 0 ); } diff --git a/test/SIM_parse_s_define/models/Classes.cpp b/test/SIM_parse_s_define/models/Classes.cpp index f1dbbb826..229fc1934 100644 --- a/test/SIM_parse_s_define/models/Classes.cpp +++ b/test/SIM_parse_s_define/models/Classes.cpp @@ -1 +1 @@ -void foo() {}; +void foo() {}; diff --git a/test/SIM_segments/models/SegmentedExecutive/src/ExampleSegments.cpp b/test/SIM_segments/models/SegmentedExecutive/src/ExampleSegments.cpp index 8fcc74b56..e592a9a69 100644 --- a/test/SIM_segments/models/SegmentedExecutive/src/ExampleSegments.cpp +++ b/test/SIM_segments/models/SegmentedExecutive/src/ExampleSegments.cpp @@ -1,35 +1,35 @@ -#include -#include "SegmentedExecutive/include/ExampleSegments.hh" +#include +#include "SegmentedExecutive/include/ExampleSegments.hh" -SegmentA::SegmentA( std::string in_segment_name , - std::string enter_job_class_str , - std::string exit_job_class_str , - Trick::IntegLoopScheduler & in_integ_sched ) : - Trick::Segment(in_segment_name , enter_job_class_str , exit_job_class_str) , - integ_sched(in_integ_sched) { } ; +SegmentA::SegmentA( std::string in_segment_name , + std::string enter_job_class_str , + std::string exit_job_class_str , + Trick::IntegLoopScheduler & in_integ_sched ) : + Trick::Segment(in_segment_name , enter_job_class_str , exit_job_class_str) , + integ_sched(in_integ_sched) { } ; -/* This custom enter routine changes the integrator and integrator cycle rate */ -int SegmentA::enter( std::string next_segment ) { - std::cout << "Switching integrators in segment A!" << std::endl ; - integ_sched.getIntegrator(Runge_Kutta_2 , 4) ; - integ_sched.set_integ_cycle(0.01) ; - return Trick::Segment::exit(next_segment) ; +/* This custom enter routine changes the integrator and integrator cycle rate */ +int SegmentA::enter( std::string next_segment ) { + std::cout << "Switching integrators in segment A!" << std::endl ; + integ_sched.getIntegrator(Runge_Kutta_2 , 4) ; + integ_sched.set_integ_cycle(0.01) ; + return Trick::Segment::exit(next_segment) ; } -/* -------------------------------------------------------------------- */ +/* -------------------------------------------------------------------- */ -SegmentB::SegmentB( std::string in_segment_name , - std::string enter_job_class_str , - std::string exit_job_class_str , - Trick::IntegLoopScheduler & in_integ_sched ) : - Trick::Segment(in_segment_name , enter_job_class_str , exit_job_class_str) , - integ_sched(in_integ_sched) { } ; +SegmentB::SegmentB( std::string in_segment_name , + std::string enter_job_class_str , + std::string exit_job_class_str , + Trick::IntegLoopScheduler & in_integ_sched ) : + Trick::Segment(in_segment_name , enter_job_class_str , exit_job_class_str) , + integ_sched(in_integ_sched) { } ; -/* This custom enter routine changes the integrator and integrator cycle rate */ -int SegmentB::enter( std::string next_segment ) { - std::cout << "Switching integrators in segment B!" << std::endl ; - integ_sched.getIntegrator(Runge_Kutta_4 , 4) ; - integ_sched.set_integ_cycle(0.1) ; - return Trick::Segment::exit(next_segment) ; +/* This custom enter routine changes the integrator and integrator cycle rate */ +int SegmentB::enter( std::string next_segment ) { + std::cout << "Switching integrators in segment B!" << std::endl ; + integ_sched.getIntegrator(Runge_Kutta_4 , 4) ; + integ_sched.set_integ_cycle(0.1) ; + return Trick::Segment::exit(next_segment) ; } diff --git a/test/SIM_segments/models/SegmentedExecutive/src/Segment.cpp b/test/SIM_segments/models/SegmentedExecutive/src/Segment.cpp index ddbaf56a1..d7a797ef0 100644 --- a/test/SIM_segments/models/SegmentedExecutive/src/Segment.cpp +++ b/test/SIM_segments/models/SegmentedExecutive/src/Segment.cpp @@ -1,45 +1,45 @@ -#include "SegmentedExecutive/include/Segment.hh" +#include "SegmentedExecutive/include/Segment.hh" -Trick::Segment::Segment( std::string in_name ) : segment_name(in_name) {} ; +Trick::Segment::Segment( std::string in_name ) : segment_name(in_name) {} ; -Trick::Segment::Segment( std::string in_name , - std::string enter_job_class_str , - std::string exit_job_class_str ) : - segment_name(in_name) { - set_enter_job_class_name(enter_job_class_str) ; - set_exit_job_class_name(exit_job_class_str) ; -} ; +Trick::Segment::Segment( std::string in_name , + std::string enter_job_class_str , + std::string exit_job_class_str ) : + segment_name(in_name) { + set_enter_job_class_name(enter_job_class_str) ; + set_exit_job_class_name(exit_job_class_str) ; +} ; -std::string Trick::Segment::get_segment_name() { - return segment_name ; +std::string Trick::Segment::get_segment_name() { + return segment_name ; } -void Trick::Segment::set_segment_name(std::string in_segment_name) { - segment_name = in_segment_name ; +void Trick::Segment::set_segment_name(std::string in_segment_name) { + segment_name = in_segment_name ; } -void Trick::Segment::set_enter_job_class_name(std::string job_class_name) { - enter_job_class_name = job_class_name ; - job_queues[enter_job_class_name] = &enter_jobs ; +void Trick::Segment::set_enter_job_class_name(std::string job_class_name) { + enter_job_class_name = job_class_name ; + job_queues[enter_job_class_name] = &enter_jobs ; } -void Trick::Segment::set_exit_job_class_name(std::string job_class_name) { - exit_job_class_name = job_class_name ; - job_queues[exit_job_class_name] = &exit_jobs ; +void Trick::Segment::set_exit_job_class_name(std::string job_class_name) { + exit_job_class_name = job_class_name ; + job_queues[exit_job_class_name] = &exit_jobs ; } -// Call the enter_jobs when entering this segment. -int Trick::Segment::enter( std::string prev_segment __attribute__((unused)) ) { - return enter_jobs.execute_all_jobs() ; +// Call the enter_jobs when entering this segment. +int Trick::Segment::enter( std::string prev_segment __attribute__((unused)) ) { + return enter_jobs.execute_all_jobs() ; } -// Call the exit_jobs when exiting this segment. -int Trick::Segment::exit( std::string next_segment __attribute__((unused)) ) { - return exit_jobs.execute_all_jobs() ; +// Call the exit_jobs when exiting this segment. +int Trick::Segment::exit( std::string next_segment __attribute__((unused)) ) { + return exit_jobs.execute_all_jobs() ; } -std::map < std::string , Trick::ScheduledJobQueue * > & Trick::Segment::get_job_queues() { - return job_queues ; +std::map < std::string , Trick::ScheduledJobQueue * > & Trick::Segment::get_job_queues() { + return job_queues ; } diff --git a/test/SIM_segments/models/SegmentedExecutive/src/SegmentedExecutive.cpp b/test/SIM_segments/models/SegmentedExecutive/src/SegmentedExecutive.cpp index 5f2177050..7d0069f45 100644 --- a/test/SIM_segments/models/SegmentedExecutive/src/SegmentedExecutive.cpp +++ b/test/SIM_segments/models/SegmentedExecutive/src/SegmentedExecutive.cpp @@ -1,256 +1,256 @@ -#include -#include -#include -#include +#include +#include +#include +#include -#include "SegmentedExecutive.hh" -#include "sim_services/Message/include/message_proto.h" -#include "sim_services/CommandLineArguments/include/command_line_protos.h" +#include "SegmentedExecutive.hh" +#include "sim_services/Message/include/message_proto.h" +#include "sim_services/CommandLineArguments/include/command_line_protos.h" -Trick::SegmentedExecutive * the_phe = NULL ; +Trick::SegmentedExecutive * the_phe = NULL ; -Trick::SegmentedExecutive::SegmentedExecutive() : curr_segment(NULL) { - // Set the global the_phe pointer for use in C bound access functions - the_phe = this ; +Trick::SegmentedExecutive::SegmentedExecutive() : curr_segment(NULL) { + // Set the global the_phe pointer for use in C bound access functions + the_phe = this ; } -int Trick::SegmentedExecutive::add_segment( Trick::Segment * ps ) { +int Trick::SegmentedExecutive::add_segment( Trick::Segment * ps ) { - // Gets the job class to job queue map for this segment and adds the job classes to the executive. - std::map < std::string , Trick::ScheduledJobQueue * >::iterator it ; - for ( it = ps->get_job_queues().begin() ; it != ps->get_job_queues().end() ; ++it ) { - class_map[(*it).first] = num_classes ; - class_to_queue[num_classes++] = (*it).second ; - } + // Gets the job class to job queue map for this segment and adds the job classes to the executive. + std::map < std::string , Trick::ScheduledJobQueue * >::iterator it ; + for ( it = ps->get_job_queues().begin() ; it != ps->get_job_queues().end() ; ++it ) { + class_map[(*it).first] = num_classes ; + class_to_queue[num_classes++] = (*it).second ; + } - // Store the segment information in a map keyed by the segment name - segment_map[ps->get_segment_name()] = ps ; + // Store the segment information in a map keyed by the segment name + segment_map[ps->get_segment_name()] = ps ; - return 0 ; + return 0 ; } /** @details - Finds all jobs that have 1 or more job tags that are a segment string. - Those jobs are saved to a set. + Finds all jobs that have 1 or more job tags that are a segment string. + Those jobs are saved to a set. */ -int Trick::SegmentedExecutive::gather_segmented_jobs() { - Trick::JobData * job ; - unsigned int ii ; - std::map < std::string , Trick::Segment * >::iterator mit ; - std::set< std::string > segment_tags ; - - for ( mit = segment_map.begin() ; mit != segment_map.end() ; ++mit ) { - segment_tags.insert((*mit).first) ; - } - - // all_jobs_vector is defined in the Trick::Executive. - for ( ii = 0 ; ii < all_jobs_vector.size() ; ii++ ) { - job = all_jobs_vector[ii] ; - /* Find the set intersection between the known segments and the current job tags. */ - std::set< std::string > intersect ; - std::set_intersection( segment_tags.begin() , segment_tags.end() , job->tags_begin() , job->tags_end() , - std::inserter( intersect, intersect.begin() ) ) ; - /* If the set intersection is not empty we have a segment. Add this job to our set of segmented jobs. */ - if ( ! intersect.empty() ) { - all_segmented_jobs.insert(job) ; - } - } - - return 0 ; +int Trick::SegmentedExecutive::gather_segmented_jobs() { + Trick::JobData * job ; + unsigned int ii ; + std::map < std::string , Trick::Segment * >::iterator mit ; + std::set< std::string > segment_tags ; + + for ( mit = segment_map.begin() ; mit != segment_map.end() ; ++mit ) { + segment_tags.insert((*mit).first) ; + } + + // all_jobs_vector is defined in the Trick::Executive. + for ( ii = 0 ; ii < all_jobs_vector.size() ; ii++ ) { + job = all_jobs_vector[ii] ; + /* Find the set intersection between the known segments and the current job tags. */ + std::set< std::string > intersect ; + std::set_intersection( segment_tags.begin() , segment_tags.end() , job->tags_begin() , job->tags_end() , + std::inserter( intersect, intersect.begin() ) ) ; + /* If the set intersection is not empty we have a segment. Add this job to our set of segmented jobs. */ + if ( ! intersect.empty() ) { + all_segmented_jobs.insert(job) ; + } + } + + return 0 ; } /** @details -Tests if the incoming segment string is a valid segment name. -If the name is valid, save the next segment for the next call of segment_switch +Tests if the incoming segment string is a valid segment name. +If the name is valid, save the next segment for the next call of segment_switch */ -int Trick::SegmentedExecutive::segment_set( std::string in_segment ) { - // Check to see if this segment string exists. - if ( segment_map.find(in_segment) != segment_map.end() ) { - next_segment_str = in_segment ; - } else { - message_publish( MSG_ERROR , "Bad Segment Name: %s\n" , in_segment.c_str() ) ; - return -1 ; - } - return 0 ; +int Trick::SegmentedExecutive::segment_set( std::string in_segment ) { + // Check to see if this segment string exists. + if ( segment_map.find(in_segment) != segment_map.end() ) { + next_segment_str = in_segment ; + } else { + message_publish( MSG_ERROR , "Bad Segment Name: %s\n" , in_segment.c_str() ) ; + return -1 ; + } + return 0 ; } /** @details -Performs segment switch. --# If there is a segment change - -# If a current segment is set. - -# Call the currrent segment exit routine - -# Call the next segment enter routine - -# else - -# Call the next segment enter routine with an empty string as the current segment - -# Turn on/off all segmented jobs. - -# Set the current segment to the next segment. +Performs segment switch. +-# If there is a segment change + -# If a current segment is set. + -# Call the currrent segment exit routine + -# Call the next segment enter routine + -# else + -# Call the next segment enter routine with an empty string as the current segment + -# Turn on/off all segmented jobs. + -# Set the current segment to the next segment. */ -int Trick::SegmentedExecutive::segment_switch() { - - Trick::Segment * next_segment = segment_map[next_segment_str] ; - - // Only do something if the next_segment is not equal to the current segment. - if ( curr_segment != next_segment ) { - if ( curr_segment != NULL ) { - // Perform current segment exit routine. - if ( curr_segment->get_segment_name().compare(next_segment_str) ) { - message_publish( MSG_INFO , "Switching from segment %s to %s\n" , - curr_segment->get_segment_name().c_str() , next_segment_str.c_str() ) ; - curr_segment->exit( next_segment_str ) ; - } - // Perform next segment enter routines - next_segment->enter( curr_segment->get_segment_name() ) ; - } else { - // If curr_segment is NULL, then this is the initial segment set. - // No need to exit current segment. - message_publish( MSG_INFO , "Setting initial segment to %s\n" , next_segment_str.c_str() ) ; - // Enter the next segment with the prev_segment set as an empty string. - next_segment->enter( std::string("") ) ; - } - - // Set the jobs to on/off according to segment - segment_set_jobs_onoff() ; - curr_segment = next_segment ; - } - - return 0 ; +int Trick::SegmentedExecutive::segment_switch() { + + Trick::Segment * next_segment = segment_map[next_segment_str] ; + + // Only do something if the next_segment is not equal to the current segment. + if ( curr_segment != next_segment ) { + if ( curr_segment != NULL ) { + // Perform current segment exit routine. + if ( curr_segment->get_segment_name().compare(next_segment_str) ) { + message_publish( MSG_INFO , "Switching from segment %s to %s\n" , + curr_segment->get_segment_name().c_str() , next_segment_str.c_str() ) ; + curr_segment->exit( next_segment_str ) ; + } + // Perform next segment enter routines + next_segment->enter( curr_segment->get_segment_name() ) ; + } else { + // If curr_segment is NULL, then this is the initial segment set. + // No need to exit current segment. + message_publish( MSG_INFO , "Setting initial segment to %s\n" , next_segment_str.c_str() ) ; + // Enter the next segment with the prev_segment set as an empty string. + next_segment->enter( std::string("") ) ; + } + + // Set the jobs to on/off according to segment + segment_set_jobs_onoff() ; + curr_segment = next_segment ; + } + + return 0 ; } /** @details -Traverses all jobs that have been marked as having a segment tag. -If the job contains the next segment tag, enable the job, else disable it. +Traverses all jobs that have been marked as having a segment tag. +If the job contains the next segment tag, enable the job, else disable it. */ -int Trick::SegmentedExecutive::segment_set_jobs_onoff() { - Trick::JobData * job ; - std::set < Trick::JobData * >::iterator it ; - - for ( it = all_segmented_jobs.begin() ; it != all_segmented_jobs.end() ; ++it ) { - job = *it ; - // Test to see if the next segment is present in the job tags. - // Set the disabled flag to the negation of the tag's presence - job->disabled = !(job->tags.count(next_segment_str)) ; - message_publish(MSG_NORMAL, "segment set job %s to %s\n" , job->name.c_str() , job->disabled ? "disabled" : "enabled" ) ; - } - - return 0 ; +int Trick::SegmentedExecutive::segment_set_jobs_onoff() { + Trick::JobData * job ; + std::set < Trick::JobData * >::iterator it ; + + for ( it = all_segmented_jobs.begin() ; it != all_segmented_jobs.end() ; ++it ) { + job = *it ; + // Test to see if the next segment is present in the job tags. + // Set the disabled flag to the negation of the tag's presence + job->disabled = !(job->tags.count(next_segment_str)) ; + message_publish(MSG_NORMAL, "segment set job %s to %s\n" , job->name.c_str() , job->disabled ? "disabled" : "enabled" ) ; + } + + return 0 ; } -/* The following routines add the segmented jobs to the S_job_execution file and - instruments the segmented jobs just like ant other job. +/* The following routines add the segmented jobs to the S_job_execution file and + instruments the segmented jobs just like ant other job. */ -int Trick::SegmentedExecutive::write_s_job_execution(FILE *fp) { +int Trick::SegmentedExecutive::write_s_job_execution(FILE *fp) { - char buf[1024]; - std::string output_dir ; + char buf[1024]; + std::string output_dir ; - // call the base Executive function - Trick::Executive::write_s_job_execution(fp) ; + // call the base Executive function + Trick::Executive::write_s_job_execution(fp) ; - /* Get full path to S_job_execution */ - output_dir = command_line_args_get_output_dir() ; - snprintf(buf, sizeof(buf), "%s/S_job_execution", output_dir.c_str()); + /* Get full path to S_job_execution */ + output_dir = command_line_args_get_output_dir() ; + snprintf(buf, sizeof(buf), "%s/S_job_execution", output_dir.c_str()); - /* Reopen the S_job_execution file. If it fails, it's not a fatal error, return 0. */ - if ((fp = fopen(buf, "a")) == NULL) { - return (0) ; - } + /* Reopen the S_job_execution file. If it fails, it's not a fatal error, return 0. */ + if ((fp = fopen(buf, "a")) == NULL) { + return (0) ; + } - fprintf(fp, "Segment Jobs:\n") ; + fprintf(fp, "Segment Jobs:\n") ; - std::map < std::string , Trick::Segment * >::iterator pmit ; - for ( pmit = segment_map.begin() ; pmit != segment_map.end() ; ++pmit ) { - Trick::Segment * pb = (*pmit).second ; - std::map < std::string , Trick::ScheduledJobQueue * >::iterator jqit ; - for ( jqit = pb->get_job_queues().begin() ; jqit != pb->get_job_queues().end() ; ++jqit ) { - (*jqit).second->write_non_sched_queue(fp) ; - } - } - fprintf(fp, "\n===================================================================================================\n") ; - fclose(fp) ; + std::map < std::string , Trick::Segment * >::iterator pmit ; + for ( pmit = segment_map.begin() ; pmit != segment_map.end() ; ++pmit ) { + Trick::Segment * pb = (*pmit).second ; + std::map < std::string , Trick::ScheduledJobQueue * >::iterator jqit ; + for ( jqit = pb->get_job_queues().begin() ; jqit != pb->get_job_queues().end() ; ++jqit ) { + (*jqit).second->write_non_sched_queue(fp) ; + } + } + fprintf(fp, "\n===================================================================================================\n") ; + fclose(fp) ; - return 0 ; + return 0 ; } -int Trick::SegmentedExecutive::instrument_job_before( Trick::JobData * instrument_job ) { +int Trick::SegmentedExecutive::instrument_job_before( Trick::JobData * instrument_job ) { - unsigned int count = 0 ; + unsigned int count = 0 ; - if ( instrument_job != NULL ) { - //call the base Executive instrument job - count = Trick::Executive::instrument_job_before( instrument_job ) ; + if ( instrument_job != NULL ) { + //call the base Executive instrument job + count = Trick::Executive::instrument_job_before( instrument_job ) ; - //go through all of the segmented jobs and instrument them. - std::map < std::string , Trick::Segment * >::iterator pmit ; - for ( pmit = segment_map.begin() ; pmit != segment_map.end() ; ++pmit ) { - Trick::Segment * pb = (*pmit).second ; - std::map < std::string , Trick::ScheduledJobQueue * >::iterator jqit ; - for ( jqit = pb->get_job_queues().begin() ; jqit != pb->get_job_queues().end() ; ++jqit ) { - (*jqit).second->instrument_before(instrument_job) ; - } - } - } + //go through all of the segmented jobs and instrument them. + std::map < std::string , Trick::Segment * >::iterator pmit ; + for ( pmit = segment_map.begin() ; pmit != segment_map.end() ; ++pmit ) { + Trick::Segment * pb = (*pmit).second ; + std::map < std::string , Trick::ScheduledJobQueue * >::iterator jqit ; + for ( jqit = pb->get_job_queues().begin() ; jqit != pb->get_job_queues().end() ; ++jqit ) { + (*jqit).second->instrument_before(instrument_job) ; + } + } + } - return count ; + return count ; } -int Trick::SegmentedExecutive::instrument_job_after( Trick::JobData * instrument_job ) { - - unsigned int count = 0 ; - - if ( instrument_job != NULL ) { - //call the base Executive instrument job - count = Trick::Executive::instrument_job_after( instrument_job ) ; - - //go through all of the segmented jobs and instrument them. - std::map < std::string , Trick::Segment * >::iterator pmit ; - for ( pmit = segment_map.begin() ; pmit != segment_map.end() ; ++pmit ) { - Trick::Segment * pb = (*pmit).second ; - std::map < std::string , Trick::ScheduledJobQueue * >::iterator jqit ; - for ( jqit = pb->get_job_queues().begin() ; jqit != pb->get_job_queues().end() ; ++jqit ) { - (*jqit).second->instrument_after(instrument_job) ; - } - } - } - return count ; +int Trick::SegmentedExecutive::instrument_job_after( Trick::JobData * instrument_job ) { + + unsigned int count = 0 ; + + if ( instrument_job != NULL ) { + //call the base Executive instrument job + count = Trick::Executive::instrument_job_after( instrument_job ) ; + + //go through all of the segmented jobs and instrument them. + std::map < std::string , Trick::Segment * >::iterator pmit ; + for ( pmit = segment_map.begin() ; pmit != segment_map.end() ; ++pmit ) { + Trick::Segment * pb = (*pmit).second ; + std::map < std::string , Trick::ScheduledJobQueue * >::iterator jqit ; + for ( jqit = pb->get_job_queues().begin() ; jqit != pb->get_job_queues().end() ; ++jqit ) { + (*jqit).second->instrument_after(instrument_job) ; + } + } + } + return count ; } -int Trick::SegmentedExecutive::instrument_job_remove(std::string in_job) { +int Trick::SegmentedExecutive::instrument_job_remove(std::string in_job) { - //call the base Executive instrument job - Trick::Executive::instrument_job_remove( in_job ) ; + //call the base Executive instrument job + Trick::Executive::instrument_job_remove( in_job ) ; - std::map < std::string , Trick::Segment * >::iterator pmit ; - for ( pmit = segment_map.begin() ; pmit != segment_map.end() ; ++pmit ) { - Trick::Segment * pb = (*pmit).second ; - std::map < std::string , Trick::ScheduledJobQueue * >::iterator jqit ; - for ( jqit = pb->get_job_queues().begin() ; jqit != pb->get_job_queues().end() ; ++jqit ) { - (*jqit).second->instrument_remove(in_job) ; - } - } - return 0 ; + std::map < std::string , Trick::Segment * >::iterator pmit ; + for ( pmit = segment_map.begin() ; pmit != segment_map.end() ; ++pmit ) { + Trick::Segment * pb = (*pmit).second ; + std::map < std::string , Trick::ScheduledJobQueue * >::iterator jqit ; + for ( jqit = pb->get_job_queues().begin() ; jqit != pb->get_job_queues().end() ; ++jqit ) { + (*jqit).second->instrument_remove(in_job) ; + } + } + return 0 ; } -// This function proides the shortcut access to set the segment in python -// trick.phexec_segment_set("string_segment") -extern "C" int exec_segment_set( std::string in_segment ) { - if ( the_phe != NULL ) { - return the_phe->segment_set(in_segment) ; - } - return -1 ; +// This function proides the shortcut access to set the segment in python +// trick.phexec_segment_set("string_segment") +extern "C" int exec_segment_set( std::string in_segment ) { + if ( the_phe != NULL ) { + return the_phe->segment_set(in_segment) ; + } + return -1 ; } -// This function proides the shortcut access to set the segment switching in python -// trick.phexec_segment_switch() -extern "C" int exec_segment_switch() { - if ( the_phe != NULL ) { - return the_phe->segment_switch() ; - } - return -1 ; +// This function proides the shortcut access to set the segment switching in python +// trick.phexec_segment_switch() +extern "C" int exec_segment_switch() { + if ( the_phe != NULL ) { + return the_phe->segment_switch() ; + } + return -1 ; } diff --git a/test/SIM_stls/models/STLCheckpoint.cpp b/test/SIM_stls/models/STLCheckpoint.cpp index 1e9839dc9..2c8453054 100644 --- a/test/SIM_stls/models/STLCheckpoint.cpp +++ b/test/SIM_stls/models/STLCheckpoint.cpp @@ -1,763 +1,763 @@ -#include "sim_services/Message/include/message_proto.h" -#include "STLCheckpoint.hh" -#include "trick/memorymanager_c_intf.h" -#include -#include -#include "sim_services/UnitTest/include/trick_tests.h" -/* These 2 constructors add different data to an STLCheckpoint. */ - -STLCheckpoint::STLCheckpoint() { - return ; +#include "sim_services/Message/include/message_proto.h" +#include "STLCheckpoint.hh" +#include "trick/memorymanager_c_intf.h" +#include +#include +#include "sim_services/UnitTest/include/trick_tests.h" +/* These 2 constructors add different data to an STLCheckpoint. */ + +STLCheckpoint::STLCheckpoint() { + return ; } -template -void compare_data_structures_with_top(T a, T b, std::string test_name) { - const char *test_suite = "STLCheckpoint"; +template +void compare_data_structures_with_top(T a, T b, std::string test_name) { + const char *test_suite = "STLCheckpoint"; - TRICK_EXPECT_EQ(a.size(), b.size(), test_suite, test_name.c_str()); - while (!a.empty()) { - TRICK_EXPECT_EQ(a.top(), b.top(), test_suite, test_name.c_str()); - a.pop(); - b.pop(); - } + TRICK_EXPECT_EQ(a.size(), b.size(), test_suite, test_name.c_str()); + while (!a.empty()) { + TRICK_EXPECT_EQ(a.top(), b.top(), test_suite, test_name.c_str()); + a.pop(); + b.pop(); + } } -int STLCheckpoint::addData() { - dataJobRun = true; - vector_vector_double = std::vector< std::vector< double > >(4, std::vector(3)); - vector_vector_vector_double = std::vector< std::vector< std::vector< double > > >(5, std::vector >(4, std::vector(3))); - - std::cout << "Adding hardcoded data to sim" << std::endl; - - double_map[44.4] = 444.4 ; - double_map[55.5] = 555.5 ; - double_map[66.6] = 666.6 ; - - string_key_map[std::string("four")] = 4 ; - string_key_map[std::string("five")] = 5 ; - string_key_map[std::string("six")] = 6 ; - - string_data_map[7] = std::string("seiben") ; - string_data_map[8] = std::string("acht") ; - string_data_map[9] = std::string("neun") ; - - std::vector< int > v ; - v.push_back(2) ; - v.push_back(4) ; - v.push_back(6) ; - v.push_back(8) ; - map_int_vector_int[1] = v ; - - std::pair< int , int > p ; - p.first = 24 ; - p.second = 30 ; - gcd[p] = 6 ; - - p.first = 50 ; - p.second = 60 ; - std::pair< int , int > q ; - q.first = 70 ; - q.second = 80 ; - map_pair_pair[p] = q ; - - p.first = 3 ; - p.second = 5 ; - v.clear() ; - v.push_back(15) ; - v.push_back(30) ; - v.push_back(45) ; - v.push_back(60) ; - common_multiples.insert(std::pair< std::pair< int, int >, std::vector< int > >(p,v)) ; - - p.first = 3 ; - p.second = 7 ; - v.clear() ; - v.push_back(21) ; - v.push_back(42) ; - v.push_back(84) ; - v.push_back(168) ; - common_multiples.insert(std::pair< std::pair< int, int >, std::vector< int > >(p,v)) ; - - string_map[std::string("sister")] = std::string("Lisa") ; - string_map[std::string("dog")] = std::string("Santa's Little Helper") ; - - int_multimap.insert(std::pair(44,444)) ; - int_multimap.insert(std::pair(55,555)) ; - int_multimap.insert(std::pair(66,666)) ; - int_multimap.insert(std::pair(44,4444)) ; - int_multimap.insert(std::pair(55,5555)) ; - int_multimap.insert(std::pair(66,6666)) ; - - string_key_multimap.insert(std::pair("four", 4)) ; - string_key_multimap.insert(std::pair("five", 5)) ; - string_key_multimap.insert(std::pair("six", 6)) ; - string_key_multimap.insert(std::pair("four", 44)) ; - string_key_multimap.insert(std::pair("five", 55)) ; - string_key_multimap.insert(std::pair("six", 66)) ; - - string_data_multimap.insert(std::pair(7, "seiben")) ; - string_data_multimap.insert(std::pair(8, "acht")) ; - string_data_multimap.insert(std::pair(9, "neun")) ; - string_data_multimap.insert(std::pair(7, "seven")) ; - string_data_multimap.insert(std::pair(8, "eight")) ; - string_data_multimap.insert(std::pair(9, "nine")) ; - - string_multimap.insert(std::pair("sister","Lisa")) ; - string_multimap.insert(std::pair("dog","Santa's Little Helper")) ; - string_multimap.insert(std::pair("sister","Meg")) ; - string_multimap.insert(std::pair("dog","Brian")) ; - - double_vector.push_back(4.0) ; - double_vector.push_back(5.0) ; - double_vector.push_back(6.0) ; - - string_vector.push_back("It") ; - string_vector.push_back("has") ; - string_vector.push_back("the") ; - string_vector.push_back("Wi-Fies") ; - - short_list.push_back(400) ; - short_list.push_back(401) ; - short_list.push_back(402) ; - - string_list.push_back("I") ; - string_list.push_back("don't") ; - string_list.push_back("care") ; - - float_deque.push_back(98.7) ; - float_deque.push_back(65.4) ; - float_deque.push_back(32.1) ; - - string_deque.push_back("Welcome") ; - string_deque.push_back("to") ; - string_deque.push_back("PhoneMart") ; - - int_set.insert(8000) ; - int_set.insert(4000) ; - int_set.insert(2000) ; - int_set.insert(1000) ; - - string_set.insert("efg") ; - string_set.insert("abc") ; - string_set.insert("def") ; - - for (int j = 0; j < 5; j++) { - std::vector temp; - for (int i = j; i < 10; i++) { - temp.push_back(i); - } - vector_set.insert(temp); - } - - pair_set.emplace("One", 1); - pair_set.emplace("Two", 2); - pair_set.emplace("Three", 3); - - std::map m; - m[5] = 500.5; - m[1] = 100.1; - std::map m2; - m2[5] = 5000.5; - m2[1] = 1000.1; - - nested_map_set.insert(m); - nested_map_set.insert(m2); - - for (int j = 0; j < 5; j++) { - std::vector temp; - for (int i = j; i < 10; i++) { - temp.push_back(i); - } - vector_queue.push(temp); - } - - - long_multiset.insert(8000) ; - long_multiset.insert(4000) ; - long_multiset.insert(4000) ; - long_multiset.insert(2000) ; - long_multiset.insert(1000) ; - - string_multiset.insert("efg") ; - string_multiset.insert("abc") ; - string_multiset.insert("def") ; - string_multiset.insert("efg") ; - string_multiset.insert("abc") ; - string_multiset.insert("def") ; - - pair_multiset.emplace(5, 5); - pair_multiset.emplace(5, 5); - pair_multiset.emplace(5, 4); - pair_multiset.emplace(4, 4); - - vec_multiset.emplace(std::vector({1,2,3,4})); - vec_multiset.emplace(std::vector({1,2,3,4})); - vec_multiset.emplace(std::vector({1,2,3,4,5})); - - - uint_stack.push(1) ; - uint_stack.push(2) ; - uint_stack.push(3) ; - uint_stack.push(4) ; - - string_stack.push("I") ; - string_stack.push("want the one") ; - string_stack.push("with the bigger") ; - string_stack.push("Gee Bees") ; - - std::vector temp_v1 = {1, 2, 3, 4}; - std::vector temp_v2 = {5, 6, 7, 8}; - stack_vector_int.push(temp_v1) ; - stack_vector_int.push(temp_v2) ; - - int_queue.push(1) ; - int_queue.push(2) ; - int_queue.push(3) ; - int_queue.push(4) ; - - string_queue.push("I") ; - string_queue.push("want") ; - string_queue.push("an") ; - string_queue.push("iPhone 4") ; - - int_priority_queue.push(3) ; - int_priority_queue.push(2) ; - int_priority_queue.push(4) ; - int_priority_queue.push(1) ; - - string_priority_queue.push("I") ; - string_priority_queue.push("want") ; - string_priority_queue.push("an") ; - string_priority_queue.push("iPhone 4") ; - - queue_vector_int.push(temp_v1) ; - queue_vector_int.push(temp_v2) ; - - priority_queue_vector_int.push(temp_v1) ; - priority_queue_vector_int.push(temp_v2) ; - - int_pair.first = 10 ; - int_pair.second = 20 ; - - string_first_pair.first = "string first" ; - string_first_pair.second = 25 ; - - string_second_pair.first = 25 ; - string_second_pair.second = "string second" ; - - string_pair.first = "pair first string" ; - string_pair.second = "pair second string" ; - - int_pair_int_int.first = 200 ; - p.first = 10 ; - p.second = 20 ; - int_pair_int_int.second = p ; - - p.first = 15 ; - p.second = 12 ; - pair_int_int_int.first = p ; - pair_int_int_int.second = 180 ; - - pair_pair_pair.first.first = 51 ; - pair_pair_pair.first.second = 52 ; - pair_pair_pair.second.first = 53 ; - pair_pair_pair.second.second = 54 ; - - int_vec_pair.first = 5; - int_vec_pair.second.push_back(5); - int_vec_pair.second.push_back(10); - int_vec_pair.second.push_back(15); - int_vec_pair.second.push_back(20); - - vec_int_pair.second = 5; - vec_int_pair.first.push_back(5); - vec_int_pair.first.push_back(10); - vec_int_pair.first.push_back(15); - vec_int_pair.first.push_back(20); - - vec_vec_pair.first.push_back(5); - vec_vec_pair.first.push_back(10); - vec_vec_pair.first.push_back(15); - vec_vec_pair.first.push_back(20); - vec_vec_pair.second.push_back(5); - vec_vec_pair.second.push_back(10); - vec_vec_pair.second.push_back(15); - vec_vec_pair.second.push_back(20); - - vector_vector_double[0][0] = 100 ; - vector_vector_double[0][1] = 101 ; - vector_vector_double[0][2] = 102 ; - vector_vector_double[1][0] = 103 ; - vector_vector_double[1][1] = 104 ; - vector_vector_double[1][2] = 105 ; - vector_vector_double[2][0] = 106 ; - vector_vector_double[2][1] = 107 ; - vector_vector_double[2][2] = 108 ; - vector_vector_double[3][0] = 109 ; - vector_vector_double[3][1] = 110 ; - vector_vector_double[3][2] = 111 ; - - vector_vector_vector_double[0][0][0] = 0 ; - vector_vector_vector_double[0][0][1] = 1 ; - vector_vector_vector_double[0][0][2] = 2 ; - vector_vector_vector_double[0][1][0] = 3 ; - vector_vector_vector_double[0][1][1] = 4 ; - vector_vector_vector_double[0][1][2] = 5 ; - vector_vector_vector_double[0][2][0] = 6 ; - vector_vector_vector_double[0][2][1] = 7 ; - vector_vector_vector_double[0][2][2] = 8 ; - vector_vector_vector_double[0][3][0] = 9 ; - vector_vector_vector_double[0][3][1] = 10 ; - vector_vector_vector_double[0][3][2] = 11 ; - - vector_vector_vector_double[1][0][0] = 1000 ; - vector_vector_vector_double[1][0][1] = 1001 ; - vector_vector_vector_double[1][0][2] = 1002 ; - vector_vector_vector_double[1][1][0] = 1003 ; - vector_vector_vector_double[1][1][1] = 1004 ; - vector_vector_vector_double[1][1][2] = 1005 ; - vector_vector_vector_double[1][2][0] = 1006 ; - vector_vector_vector_double[1][2][1] = 1007 ; - vector_vector_vector_double[1][2][2] = 1008 ; - vector_vector_vector_double[1][3][0] = 1009 ; - vector_vector_vector_double[1][3][1] = 1010 ; - vector_vector_vector_double[1][3][2] = 1011 ; - - vector_vector_vector_double[2][0][0] = 2000 ; - vector_vector_vector_double[2][0][1] = 2001 ; - vector_vector_vector_double[2][0][2] = 2002 ; - vector_vector_vector_double[2][1][0] = 2003 ; - vector_vector_vector_double[2][1][1] = 2004 ; - vector_vector_vector_double[2][1][2] = 2005 ; - vector_vector_vector_double[2][2][0] = 2006 ; - vector_vector_vector_double[2][2][1] = 2007 ; - vector_vector_vector_double[2][2][2] = 2008 ; - vector_vector_vector_double[2][3][0] = 2009 ; - vector_vector_vector_double[2][3][1] = 2010 ; - vector_vector_vector_double[2][3][2] = 2011 ; - - vector_vector_vector_double[3][0][0] = 3000 ; - vector_vector_vector_double[3][0][1] = 3001 ; - vector_vector_vector_double[3][0][2] = 3002 ; - vector_vector_vector_double[3][1][0] = 3003 ; - vector_vector_vector_double[3][1][1] = 3004 ; - vector_vector_vector_double[3][1][2] = 3005 ; - vector_vector_vector_double[3][2][0] = 3006 ; - vector_vector_vector_double[3][2][1] = 3007 ; - vector_vector_vector_double[3][2][2] = 3008 ; - vector_vector_vector_double[3][3][0] = 3009 ; - vector_vector_vector_double[3][3][1] = 3010 ; - vector_vector_vector_double[3][3][2] = 3011 ; - - vector_vector_vector_double[4][0][0] = 4000 ; - vector_vector_vector_double[4][0][1] = 4001 ; - vector_vector_vector_double[4][0][2] = 4002 ; - vector_vector_vector_double[4][1][0] = 4003 ; - vector_vector_vector_double[4][1][1] = 4004 ; - vector_vector_vector_double[4][1][2] = 4005 ; - vector_vector_vector_double[4][2][0] = 4006 ; - vector_vector_vector_double[4][2][1] = 4007 ; - vector_vector_vector_double[4][2][2] = 4008 ; - vector_vector_vector_double[4][3][0] = 4009 ; - vector_vector_vector_double[4][3][1] = 4010 ; - vector_vector_vector_double[4][3][2] = 4011 ; - - for (int i = 0; i < 10; i++) { - UserClass temp; - for (int j = 0; j < 5; j++) { - temp.a[j] = i+j; - } - temp.b = 8888888888; - temp.c = "Here is a test string"; - - // We'll just make a pointer to the same stuff - - UserClass * user_class_ptr = (UserClass *) TMM_declare_var_s("UserClass"); - for (int j = 0; j < 5; j++) { - user_class_ptr->a[j] = i+j; - } - user_class_ptr->b = 8888888888; - user_class_ptr->c = "Here is a test string"; - - temp.d = user_class_ptr; - - vec_user_simple.emplace_back(temp); - } - - for (int i = 0; i < 10; i++) { - SimpleWrapper temp_wrapper; - temp_wrapper.a = 888; - for (int j = i; j < i+10; j++) { - temp_wrapper.vec.push_back(j); - } - vec_user_defined.emplace_back(temp_wrapper); - } - - for (int i = 0; i < 10; i++) { - SimpleWrapper * temp_wrapper = (SimpleWrapper *) TMM_declare_var_s("SimpleWrapper"); - temp_wrapper->a = 888; - for (int j = i; j < i+10; j++) { - temp_wrapper->vec.push_back(j); - } - vec_user_defined_ptr.push_back(temp_wrapper); - } - - return 0; +int STLCheckpoint::addData() { + dataJobRun = true; + vector_vector_double = std::vector< std::vector< double > >(4, std::vector(3)); + vector_vector_vector_double = std::vector< std::vector< std::vector< double > > >(5, std::vector >(4, std::vector(3))); + + std::cout << "Adding hardcoded data to sim" << std::endl; + + double_map[44.4] = 444.4 ; + double_map[55.5] = 555.5 ; + double_map[66.6] = 666.6 ; + + string_key_map[std::string("four")] = 4 ; + string_key_map[std::string("five")] = 5 ; + string_key_map[std::string("six")] = 6 ; + + string_data_map[7] = std::string("seiben") ; + string_data_map[8] = std::string("acht") ; + string_data_map[9] = std::string("neun") ; + + std::vector< int > v ; + v.push_back(2) ; + v.push_back(4) ; + v.push_back(6) ; + v.push_back(8) ; + map_int_vector_int[1] = v ; + + std::pair< int , int > p ; + p.first = 24 ; + p.second = 30 ; + gcd[p] = 6 ; + + p.first = 50 ; + p.second = 60 ; + std::pair< int , int > q ; + q.first = 70 ; + q.second = 80 ; + map_pair_pair[p] = q ; + + p.first = 3 ; + p.second = 5 ; + v.clear() ; + v.push_back(15) ; + v.push_back(30) ; + v.push_back(45) ; + v.push_back(60) ; + common_multiples.insert(std::pair< std::pair< int, int >, std::vector< int > >(p,v)) ; + + p.first = 3 ; + p.second = 7 ; + v.clear() ; + v.push_back(21) ; + v.push_back(42) ; + v.push_back(84) ; + v.push_back(168) ; + common_multiples.insert(std::pair< std::pair< int, int >, std::vector< int > >(p,v)) ; + + string_map[std::string("sister")] = std::string("Lisa") ; + string_map[std::string("dog")] = std::string("Santa's Little Helper") ; + + int_multimap.insert(std::pair(44,444)) ; + int_multimap.insert(std::pair(55,555)) ; + int_multimap.insert(std::pair(66,666)) ; + int_multimap.insert(std::pair(44,4444)) ; + int_multimap.insert(std::pair(55,5555)) ; + int_multimap.insert(std::pair(66,6666)) ; + + string_key_multimap.insert(std::pair("four", 4)) ; + string_key_multimap.insert(std::pair("five", 5)) ; + string_key_multimap.insert(std::pair("six", 6)) ; + string_key_multimap.insert(std::pair("four", 44)) ; + string_key_multimap.insert(std::pair("five", 55)) ; + string_key_multimap.insert(std::pair("six", 66)) ; + + string_data_multimap.insert(std::pair(7, "seiben")) ; + string_data_multimap.insert(std::pair(8, "acht")) ; + string_data_multimap.insert(std::pair(9, "neun")) ; + string_data_multimap.insert(std::pair(7, "seven")) ; + string_data_multimap.insert(std::pair(8, "eight")) ; + string_data_multimap.insert(std::pair(9, "nine")) ; + + string_multimap.insert(std::pair("sister","Lisa")) ; + string_multimap.insert(std::pair("dog","Santa's Little Helper")) ; + string_multimap.insert(std::pair("sister","Meg")) ; + string_multimap.insert(std::pair("dog","Brian")) ; + + double_vector.push_back(4.0) ; + double_vector.push_back(5.0) ; + double_vector.push_back(6.0) ; + + string_vector.push_back("It") ; + string_vector.push_back("has") ; + string_vector.push_back("the") ; + string_vector.push_back("Wi-Fies") ; + + short_list.push_back(400) ; + short_list.push_back(401) ; + short_list.push_back(402) ; + + string_list.push_back("I") ; + string_list.push_back("don't") ; + string_list.push_back("care") ; + + float_deque.push_back(98.7) ; + float_deque.push_back(65.4) ; + float_deque.push_back(32.1) ; + + string_deque.push_back("Welcome") ; + string_deque.push_back("to") ; + string_deque.push_back("PhoneMart") ; + + int_set.insert(8000) ; + int_set.insert(4000) ; + int_set.insert(2000) ; + int_set.insert(1000) ; + + string_set.insert("efg") ; + string_set.insert("abc") ; + string_set.insert("def") ; + + for (int j = 0; j < 5; j++) { + std::vector temp; + for (int i = j; i < 10; i++) { + temp.push_back(i); + } + vector_set.insert(temp); + } + + pair_set.emplace("One", 1); + pair_set.emplace("Two", 2); + pair_set.emplace("Three", 3); + + std::map m; + m[5] = 500.5; + m[1] = 100.1; + std::map m2; + m2[5] = 5000.5; + m2[1] = 1000.1; + + nested_map_set.insert(m); + nested_map_set.insert(m2); + + for (int j = 0; j < 5; j++) { + std::vector temp; + for (int i = j; i < 10; i++) { + temp.push_back(i); + } + vector_queue.push(temp); + } + + + long_multiset.insert(8000) ; + long_multiset.insert(4000) ; + long_multiset.insert(4000) ; + long_multiset.insert(2000) ; + long_multiset.insert(1000) ; + + string_multiset.insert("efg") ; + string_multiset.insert("abc") ; + string_multiset.insert("def") ; + string_multiset.insert("efg") ; + string_multiset.insert("abc") ; + string_multiset.insert("def") ; + + pair_multiset.emplace(5, 5); + pair_multiset.emplace(5, 5); + pair_multiset.emplace(5, 4); + pair_multiset.emplace(4, 4); + + vec_multiset.emplace(std::vector({1,2,3,4})); + vec_multiset.emplace(std::vector({1,2,3,4})); + vec_multiset.emplace(std::vector({1,2,3,4,5})); + + + uint_stack.push(1) ; + uint_stack.push(2) ; + uint_stack.push(3) ; + uint_stack.push(4) ; + + string_stack.push("I") ; + string_stack.push("want the one") ; + string_stack.push("with the bigger") ; + string_stack.push("Gee Bees") ; + + std::vector temp_v1 = {1, 2, 3, 4}; + std::vector temp_v2 = {5, 6, 7, 8}; + stack_vector_int.push(temp_v1) ; + stack_vector_int.push(temp_v2) ; + + int_queue.push(1) ; + int_queue.push(2) ; + int_queue.push(3) ; + int_queue.push(4) ; + + string_queue.push("I") ; + string_queue.push("want") ; + string_queue.push("an") ; + string_queue.push("iPhone 4") ; + + int_priority_queue.push(3) ; + int_priority_queue.push(2) ; + int_priority_queue.push(4) ; + int_priority_queue.push(1) ; + + string_priority_queue.push("I") ; + string_priority_queue.push("want") ; + string_priority_queue.push("an") ; + string_priority_queue.push("iPhone 4") ; + + queue_vector_int.push(temp_v1) ; + queue_vector_int.push(temp_v2) ; + + priority_queue_vector_int.push(temp_v1) ; + priority_queue_vector_int.push(temp_v2) ; + + int_pair.first = 10 ; + int_pair.second = 20 ; + + string_first_pair.first = "string first" ; + string_first_pair.second = 25 ; + + string_second_pair.first = 25 ; + string_second_pair.second = "string second" ; + + string_pair.first = "pair first string" ; + string_pair.second = "pair second string" ; + + int_pair_int_int.first = 200 ; + p.first = 10 ; + p.second = 20 ; + int_pair_int_int.second = p ; + + p.first = 15 ; + p.second = 12 ; + pair_int_int_int.first = p ; + pair_int_int_int.second = 180 ; + + pair_pair_pair.first.first = 51 ; + pair_pair_pair.first.second = 52 ; + pair_pair_pair.second.first = 53 ; + pair_pair_pair.second.second = 54 ; + + int_vec_pair.first = 5; + int_vec_pair.second.push_back(5); + int_vec_pair.second.push_back(10); + int_vec_pair.second.push_back(15); + int_vec_pair.second.push_back(20); + + vec_int_pair.second = 5; + vec_int_pair.first.push_back(5); + vec_int_pair.first.push_back(10); + vec_int_pair.first.push_back(15); + vec_int_pair.first.push_back(20); + + vec_vec_pair.first.push_back(5); + vec_vec_pair.first.push_back(10); + vec_vec_pair.first.push_back(15); + vec_vec_pair.first.push_back(20); + vec_vec_pair.second.push_back(5); + vec_vec_pair.second.push_back(10); + vec_vec_pair.second.push_back(15); + vec_vec_pair.second.push_back(20); + + vector_vector_double[0][0] = 100 ; + vector_vector_double[0][1] = 101 ; + vector_vector_double[0][2] = 102 ; + vector_vector_double[1][0] = 103 ; + vector_vector_double[1][1] = 104 ; + vector_vector_double[1][2] = 105 ; + vector_vector_double[2][0] = 106 ; + vector_vector_double[2][1] = 107 ; + vector_vector_double[2][2] = 108 ; + vector_vector_double[3][0] = 109 ; + vector_vector_double[3][1] = 110 ; + vector_vector_double[3][2] = 111 ; + + vector_vector_vector_double[0][0][0] = 0 ; + vector_vector_vector_double[0][0][1] = 1 ; + vector_vector_vector_double[0][0][2] = 2 ; + vector_vector_vector_double[0][1][0] = 3 ; + vector_vector_vector_double[0][1][1] = 4 ; + vector_vector_vector_double[0][1][2] = 5 ; + vector_vector_vector_double[0][2][0] = 6 ; + vector_vector_vector_double[0][2][1] = 7 ; + vector_vector_vector_double[0][2][2] = 8 ; + vector_vector_vector_double[0][3][0] = 9 ; + vector_vector_vector_double[0][3][1] = 10 ; + vector_vector_vector_double[0][3][2] = 11 ; + + vector_vector_vector_double[1][0][0] = 1000 ; + vector_vector_vector_double[1][0][1] = 1001 ; + vector_vector_vector_double[1][0][2] = 1002 ; + vector_vector_vector_double[1][1][0] = 1003 ; + vector_vector_vector_double[1][1][1] = 1004 ; + vector_vector_vector_double[1][1][2] = 1005 ; + vector_vector_vector_double[1][2][0] = 1006 ; + vector_vector_vector_double[1][2][1] = 1007 ; + vector_vector_vector_double[1][2][2] = 1008 ; + vector_vector_vector_double[1][3][0] = 1009 ; + vector_vector_vector_double[1][3][1] = 1010 ; + vector_vector_vector_double[1][3][2] = 1011 ; + + vector_vector_vector_double[2][0][0] = 2000 ; + vector_vector_vector_double[2][0][1] = 2001 ; + vector_vector_vector_double[2][0][2] = 2002 ; + vector_vector_vector_double[2][1][0] = 2003 ; + vector_vector_vector_double[2][1][1] = 2004 ; + vector_vector_vector_double[2][1][2] = 2005 ; + vector_vector_vector_double[2][2][0] = 2006 ; + vector_vector_vector_double[2][2][1] = 2007 ; + vector_vector_vector_double[2][2][2] = 2008 ; + vector_vector_vector_double[2][3][0] = 2009 ; + vector_vector_vector_double[2][3][1] = 2010 ; + vector_vector_vector_double[2][3][2] = 2011 ; + + vector_vector_vector_double[3][0][0] = 3000 ; + vector_vector_vector_double[3][0][1] = 3001 ; + vector_vector_vector_double[3][0][2] = 3002 ; + vector_vector_vector_double[3][1][0] = 3003 ; + vector_vector_vector_double[3][1][1] = 3004 ; + vector_vector_vector_double[3][1][2] = 3005 ; + vector_vector_vector_double[3][2][0] = 3006 ; + vector_vector_vector_double[3][2][1] = 3007 ; + vector_vector_vector_double[3][2][2] = 3008 ; + vector_vector_vector_double[3][3][0] = 3009 ; + vector_vector_vector_double[3][3][1] = 3010 ; + vector_vector_vector_double[3][3][2] = 3011 ; + + vector_vector_vector_double[4][0][0] = 4000 ; + vector_vector_vector_double[4][0][1] = 4001 ; + vector_vector_vector_double[4][0][2] = 4002 ; + vector_vector_vector_double[4][1][0] = 4003 ; + vector_vector_vector_double[4][1][1] = 4004 ; + vector_vector_vector_double[4][1][2] = 4005 ; + vector_vector_vector_double[4][2][0] = 4006 ; + vector_vector_vector_double[4][2][1] = 4007 ; + vector_vector_vector_double[4][2][2] = 4008 ; + vector_vector_vector_double[4][3][0] = 4009 ; + vector_vector_vector_double[4][3][1] = 4010 ; + vector_vector_vector_double[4][3][2] = 4011 ; + + for (int i = 0; i < 10; i++) { + UserClass temp; + for (int j = 0; j < 5; j++) { + temp.a[j] = i+j; + } + temp.b = 8888888888; + temp.c = "Here is a test string"; + + // We'll just make a pointer to the same stuff + + UserClass * user_class_ptr = (UserClass *) TMM_declare_var_s("UserClass"); + for (int j = 0; j < 5; j++) { + user_class_ptr->a[j] = i+j; + } + user_class_ptr->b = 8888888888; + user_class_ptr->c = "Here is a test string"; + + temp.d = user_class_ptr; + + vec_user_simple.emplace_back(temp); + } + + for (int i = 0; i < 10; i++) { + SimpleWrapper temp_wrapper; + temp_wrapper.a = 888; + for (int j = i; j < i+10; j++) { + temp_wrapper.vec.push_back(j); + } + vec_user_defined.emplace_back(temp_wrapper); + } + + for (int i = 0; i < 10; i++) { + SimpleWrapper * temp_wrapper = (SimpleWrapper *) TMM_declare_var_s("SimpleWrapper"); + temp_wrapper->a = 888; + for (int j = i; j < i+10; j++) { + temp_wrapper->vec.push_back(j); + } + vec_user_defined_ptr.push_back(temp_wrapper); + } + + return 0; } -int STLCheckpoint::print() { - message_publish(1,"Quack!\n") ; - message_publish(1, "Double vector size: %d", double_vector.size() ); - message_publish(1,"double_vector: %f %f %f\n", double_vector[0], double_vector[1], double_vector[2]) ; - message_publish(1,"vector_vector_double[1]: %f %f %f\n", - vector_vector_double[1][0], vector_vector_double[1][1], vector_vector_double[1][2]) ; - message_publish(1,"vector_vector_vector_double[4][2]: %f %f %f\n", - vector_vector_vector_double[4][2][0], vector_vector_vector_double[4][2][1], vector_vector_vector_double[4][2][2]) ; - message_publish(1,"string_vector[0]: %s\n", string_vector[0].c_str()) ; - message_publish(1,"map_int_vector_int[1][1] = %d\n", map_int_vector_int[1][1]) ; - message_publish(1,"gcd = %d\n", gcd[std::pair(24,30)]) ; - message_publish(1,"common_multiples = %d\n", common_multiples[std::pair(3,5)][1]) ; - message_publish(1,"common_multiples = %d\n", common_multiples[std::pair(3,5)][1]) ; - message_publish(1,"int_pair_int_int.second.second = %d\n", int_pair_int_int.second.second) ; - message_publish(1,"pair_int_int_int.first.second = %d\n", pair_int_int_int.first.second) ; - message_publish(1,"pair_pair_pair.second.first = %d\n", pair_pair_pair.second.first) ; - message_publish(1,"int_queue.front = %d\n", int_queue.front()) ; - message_publish(1,"int_priority_queue.top = %d\n", int_priority_queue.top()) ; - message_publish(1,"uint_stack.top = %d\n", uint_stack.top()) ; - message_publish(1,"queue_vector_int.front()[3] = %d\n", queue_vector_int.front()[3]) ; - message_publish(1,"priority_queue_vector_int.top()[2] = %d\n", priority_queue_vector_int.top()[2]) ; - message_publish(1,"stack_vector_int.top()[1] = %d\n", stack_vector_int.top()[1]) ; - return 0 ; +int STLCheckpoint::print() { + message_publish(1,"Quack!\n") ; + message_publish(1, "Double vector size: %d", double_vector.size() ); + message_publish(1,"double_vector: %f %f %f\n", double_vector[0], double_vector[1], double_vector[2]) ; + message_publish(1,"vector_vector_double[1]: %f %f %f\n", + vector_vector_double[1][0], vector_vector_double[1][1], vector_vector_double[1][2]) ; + message_publish(1,"vector_vector_vector_double[4][2]: %f %f %f\n", + vector_vector_vector_double[4][2][0], vector_vector_vector_double[4][2][1], vector_vector_vector_double[4][2][2]) ; + message_publish(1,"string_vector[0]: %s\n", string_vector[0].c_str()) ; + message_publish(1,"map_int_vector_int[1][1] = %d\n", map_int_vector_int[1][1]) ; + message_publish(1,"gcd = %d\n", gcd[std::pair(24,30)]) ; + message_publish(1,"common_multiples = %d\n", common_multiples[std::pair(3,5)][1]) ; + message_publish(1,"common_multiples = %d\n", common_multiples[std::pair(3,5)][1]) ; + message_publish(1,"int_pair_int_int.second.second = %d\n", int_pair_int_int.second.second) ; + message_publish(1,"pair_int_int_int.first.second = %d\n", pair_int_int_int.first.second) ; + message_publish(1,"pair_pair_pair.second.first = %d\n", pair_pair_pair.second.first) ; + message_publish(1,"int_queue.front = %d\n", int_queue.front()) ; + message_publish(1,"int_priority_queue.top = %d\n", int_priority_queue.top()) ; + message_publish(1,"uint_stack.top = %d\n", uint_stack.top()) ; + message_publish(1,"queue_vector_int.front()[3] = %d\n", queue_vector_int.front()[3]) ; + message_publish(1,"priority_queue_vector_int.top()[2] = %d\n", priority_queue_vector_int.top()[2]) ; + message_publish(1,"stack_vector_int.top()[1] = %d\n", stack_vector_int.top()[1]) ; + return 0 ; } -int STLCheckpoint::test() { - std::cout << "Running test jobs" << std::endl; - const char *test_suite = "STLCheckpoint"; - - TRICK_EXPECT_EQ( double_vector.size(), 3, test_suite, "double_vector size"); - TRICK_EXPECT_EQ( double_vector[0], 4, test_suite, "double_vector[0]"); - TRICK_EXPECT_EQ( double_vector[1], 5, test_suite, "double_vector[1]"); - TRICK_EXPECT_EQ( double_vector[2], 6, test_suite, "double_vector[2]"); - TRICK_EXPECT_EQ( vector_vector_double[1][0], 103, test_suite, "vector_vector_double[1][0]"); - TRICK_EXPECT_EQ( vector_vector_double[1][1], 104, test_suite, "vector_vector_double[1][1]"); - TRICK_EXPECT_EQ( vector_vector_double[1][2], 105, test_suite, "vector_vector_double[1][2]"); - TRICK_EXPECT_EQ( vector_vector_vector_double[4][2][0], 4006, test_suite, "vector_vector_vector_double[4][2][0]"); - TRICK_EXPECT_EQ( vector_vector_vector_double[4][2][1], 4007, test_suite, "vector_vector_vector_double[4][2][1]"); - TRICK_EXPECT_EQ( vector_vector_vector_double[4][2][2], 4008, test_suite, "vector_vector_vector_double[4][2][2]"); - TRICK_EXPECT_EQ( string_vector[0], std::string("It"), test_suite, "string_vector"); - - TRICK_EXPECT_EQ( double_map[44.4], 444.4, test_suite, "double_map[44.4]" ); - - TRICK_EXPECT_EQ( string_data_map[7], std::string("seiben"), test_suite, "string_data_map[7]" ); - TRICK_EXPECT_EQ( string_data_map[9], std::string("neun") , test_suite, "string_data_map[9]"); - - std::vector< int > v ; - v.push_back(2) ; - v.push_back(4) ; - v.push_back(6) ; - v.push_back(8) ; - TRICK_EXPECT_EQ( map_int_vector_int[1], v, test_suite, "map_int_vector_int[1]"); - - std::pair< int , int > p ; - p.first = 24 ; - p.second = 30 ; - TRICK_EXPECT_EQ(gcd[p], 6, test_suite, "gcd[p]" ); - - p.first = 50 ; - p.second = 60 ; - std::pair< int , int > q ; - q.first = 70 ; - q.second = 80 ; - TRICK_EXPECT_EQ( map_pair_pair[p], q, test_suite, "map_pair_pair[p]" ); - - p.first = 3 ; - p.second = 5 ; - v.clear() ; - v.push_back(15) ; - v.push_back(30) ; - v.push_back(45) ; - v.push_back(60) ; - TRICK_EXPECT_EQ( common_multiples[p], v, test_suite, "common_multiples" ); - - p.first = 3 ; - p.second = 7 ; - v.clear() ; - v.push_back(21) ; - v.push_back(42) ; - v.push_back(84) ; - v.push_back(168) ; - TRICK_EXPECT_EQ( common_multiples[p], v, test_suite, "common_multiples" ); - - - TRICK_EXPECT_EQ( string_map["sister"], "Lisa", test_suite, "string_map[sister]" ); - TRICK_EXPECT_EQ( string_map["dog"], "Santa's Little Helper", test_suite, "string_map[dog]" ); - - - // The easiest way to test the multimaps is to just rebuild copies and compare - std::multimap int_multimap_copy; - int_multimap_copy.insert(std::pair(44,444)) ; - int_multimap_copy.insert(std::pair(55,555)) ; - int_multimap_copy.insert(std::pair(66,666)) ; - int_multimap_copy.insert(std::pair(44,4444)) ; - int_multimap_copy.insert(std::pair(55,5555)) ; - int_multimap_copy.insert(std::pair(66,6666)) ; - TRICK_EXPECT_EQ(int_multimap, int_multimap_copy , test_suite, "int_multimap"); - - int_multimap_copy.insert(std::pair(66,66666)) ; - TRICK_EXPECT_NE(int_multimap, int_multimap_copy , test_suite, "int_multimap_fail"); - - std::multimap string_key_multimap_copy; - string_key_multimap_copy.insert(std::pair("four", 4)) ; - string_key_multimap_copy.insert(std::pair("five", 5)) ; - string_key_multimap_copy.insert(std::pair("six", 6)) ; - string_key_multimap_copy.insert(std::pair("four", 44)) ; - string_key_multimap_copy.insert(std::pair("five", 55)) ; - string_key_multimap_copy.insert(std::pair("six", 66)) ; - TRICK_EXPECT_EQ(string_key_multimap, string_key_multimap_copy , test_suite, "string_key_multimap"); - - std::multimap string_data_multimap_copy; - string_data_multimap_copy.insert(std::pair(7, "seiben")) ; - string_data_multimap_copy.insert(std::pair(8, "acht")) ; - string_data_multimap_copy.insert(std::pair(9, "neun")) ; - string_data_multimap_copy.insert(std::pair(7, "seven")) ; - string_data_multimap_copy.insert(std::pair(8, "eight")) ; - string_data_multimap_copy.insert(std::pair(9, "nine")) ; - TRICK_EXPECT_EQ(string_data_multimap, string_data_multimap_copy , test_suite, "string_data_multimap"); - - std::multimap string_multimap_copy; - string_multimap_copy.insert(std::pair("sister","Lisa")) ; - string_multimap_copy.insert(std::pair("dog","Santa's Little Helper")) ; - string_multimap_copy.insert(std::pair("sister","Meg")) ; - string_multimap_copy.insert(std::pair("dog","Brian")) ; - TRICK_EXPECT_EQ(string_multimap, string_multimap_copy , test_suite, "string_multimap"); - - - // TODO: fix this case - // TRICK_EXPECT_EQ(vec_user_defined.size(), 10, test_suite, "vec_user_defined"); - // for (int i = 0; i < vec_user_defined.size(); i++) { - // TRICK_EXPECT_EQ(vec_user_defined[i].vec.size(), 10, test_suite, "vec_user_defined"); - // TRICK_EXPECT_EQ(vec_user_defined[i].a, 888, test_suite, "vec_user_defined"); - // for (int j = i; j < i+vec_user_defined[i].vec.size(); j++) { - // TRICK_EXPECT_EQ(vec_user_defined[i].vec[j-i], j, test_suite, "vec_user_defined"); - // } - // } - - TRICK_EXPECT_EQ(vec_user_defined_ptr.size(), 10, test_suite, "vec_user_defined_ptr"); - for (int i = 0; i < vec_user_defined_ptr.size(); i++) { - TRICK_EXPECT_EQ(vec_user_defined_ptr[i]->vec.size(), 10, test_suite, "vec_user_defined_ptr"); - TRICK_EXPECT_EQ(vec_user_defined_ptr[i]->a, 888, test_suite, "vec_user_defined_ptr"); - std::vector test_vec; - for (int j = i; j < i+vec_user_defined_ptr[i]->vec.size(); j++) { - test_vec.push_back(j); - } - TRICK_EXPECT_EQ(vec_user_defined_ptr[i]->vec, test_vec, test_suite, "vec_user_defined_ptr"); - } - - - std::vector string_vector_copy = {"It", "has", "the", "Wi-Fies"}; - TRICK_EXPECT_EQ(string_vector, string_vector_copy, test_suite, "string_vector"); - - std::list short_list_copy = {400, 401, 402}; - int list_index = 0; - TRICK_EXPECT_EQ(short_list, short_list_copy, test_suite, "short_list"); - - std::list string_list_copy = {"I", "don't", "care"}; - TRICK_EXPECT_EQ(string_list, string_list_copy, test_suite, "string_list"); - - std::deque float_deque_copy = {98.7, 65.4, 32.1}; - TRICK_EXPECT_EQ(float_deque, float_deque_copy, test_suite, "float_deque"); - - std::deque string_deque_copy = {"Welcome", "to", "PhoneMart"}; - TRICK_EXPECT_EQ(string_deque, string_deque_copy, test_suite, "string_deque"); - - std::set int_set_copy = {8000, 4000, 2000, 1000}; - TRICK_EXPECT_EQ(int_set, int_set_copy, test_suite, "int_set"); - - std::set string_set_copy = {"efg", "abc", "def"}; - TRICK_EXPECT_EQ(string_set, string_set_copy, test_suite, "string_set"); - - std::set> vector_set_copy; - for (int j = 0; j < 5; j++) { - std::vector temp; - for (int i = j; i < 10; i++) { - temp.push_back(i); - } - vector_set_copy.insert(temp); - } - TRICK_EXPECT_EQ(vector_set, vector_set_copy, test_suite, "vector_set"); - - std::set> pair_set_copy; - pair_set_copy.emplace("One", 1); - pair_set_copy.emplace("Two", 2); - pair_set_copy.emplace("Three", 3); - TRICK_EXPECT_EQ(pair_set, pair_set_copy, test_suite, "pair_set"); - - std::set> nested_map_set_copy; - std::map m; - m[5] = 500.5; - m[1] = 100.1; - std::map m2; - m2[5] = 5000.5; - m2[1] = 1000.1; - nested_map_set_copy.insert(m); - nested_map_set_copy.insert(m2); - TRICK_EXPECT_EQ(nested_map_set, nested_map_set_copy, test_suite, "nested_map_set"); - - std::queue> vector_queue_copy; - for (int j = 0; j < 5; j++) { - std::vector temp; - for (int i = j; i < 10; i++) { - temp.push_back(i); - } - vector_queue_copy.push(temp); - } - TRICK_EXPECT_EQ(vector_queue, vector_queue_copy, test_suite, "vector_queue"); - - std::multiset long_multiset_copy = {8000, 4000, 4000, 2000, 1000}; - TRICK_EXPECT_EQ(long_multiset, long_multiset_copy, test_suite, "long_multiset"); - - std::multiset string_multiset_copy = {"efg", "abc", "def", "efg", "abc", "def"}; - TRICK_EXPECT_EQ(string_multiset, string_multiset_copy, test_suite, "string_multiset"); - - std::multiset> pair_multiset_copy; - pair_multiset_copy.emplace(5, 5); - pair_multiset_copy.emplace(5, 5); - pair_multiset_copy.emplace(5, 4); - pair_multiset_copy.emplace(4, 4); - TRICK_EXPECT_EQ(pair_multiset, pair_multiset_copy, test_suite, "pair_multiset"); - - std::multiset> vec_multiset_copy; - vec_multiset_copy.emplace(std::vector({1,2,3,4})); - vec_multiset_copy.emplace(std::vector({1,2,3,4})); - vec_multiset_copy.emplace(std::vector({1,2,3,4,5})); - TRICK_EXPECT_EQ(vec_multiset, vec_multiset_copy, test_suite, "vec_multiset"); - - std::stack uint_stack_copy; - uint_stack_copy.push(1) ; - uint_stack_copy.push(2) ; - uint_stack_copy.push(3) ; - uint_stack_copy.push(4) ; - TRICK_EXPECT_EQ(uint_stack, uint_stack_copy, test_suite, "uint_stack"); - - std::stack string_stack_copy; - string_stack_copy.push("I") ; - string_stack_copy.push("want the one") ; - string_stack_copy.push("with the bigger") ; - string_stack_copy.push("Gee Bees") ; - TRICK_EXPECT_EQ(string_stack, string_stack_copy, test_suite, "string_stack"); - - std::stack> stack_vector_int_copy; - std::vector temp_v1 = {1, 2, 3, 4}; - std::vector temp_v2 = {5, 6, 7, 8}; - stack_vector_int_copy.emplace(temp_v1) ; - stack_vector_int_copy.emplace(temp_v2) ; - TRICK_EXPECT_EQ(stack_vector_int, stack_vector_int_copy, test_suite, "stack_vector_int"); - - std::queue int_queue_copy; - int_queue_copy.push(1) ; - int_queue_copy.push(2) ; - int_queue_copy.push(3) ; - int_queue_copy.push(4) ; - TRICK_EXPECT_EQ(int_queue, int_queue_copy, test_suite, "int_queue"); - - std::queue string_queue_copy; - string_queue_copy.push("I") ; - string_queue_copy.push("want") ; - string_queue_copy.push("an") ; - string_queue_copy.push("iPhone 4") ; - TRICK_EXPECT_EQ(string_queue, string_queue_copy, test_suite, "string_queue"); - - // Why doesn't priority_queue have the == operator but literally everything else does >:( - std::priority_queue int_priority_queue_copy; - int_priority_queue_copy.push(3) ; - int_priority_queue_copy.push(2) ; - int_priority_queue_copy.push(4) ; - int_priority_queue_copy.push(1) ; - compare_data_structures_with_top(int_priority_queue_copy, int_priority_queue, "int_priority_queue"); - - std::priority_queue string_priority_queue_copy; - string_priority_queue_copy.push("I") ; - string_priority_queue_copy.push("want") ; - string_priority_queue_copy.push("an") ; - string_priority_queue_copy.push("iPhone 4") ; - compare_data_structures_with_top(string_priority_queue_copy, string_priority_queue, "string_priority_queue"); - - std::queue> queue_vector_int_copy; - queue_vector_int_copy.emplace(temp_v1) ; - queue_vector_int_copy.emplace(temp_v2) ; - TRICK_EXPECT_EQ(queue_vector_int, queue_vector_int_copy, test_suite, "queue_vector_int"); - - std::priority_queue> priority_queue_vector_int_copy; - priority_queue_vector_int_copy.emplace(temp_v1) ; - priority_queue_vector_int_copy.emplace(temp_v2) ; - compare_data_structures_with_top(priority_queue_vector_int_copy, priority_queue_vector_int, "priority_queue_vector_int"); - - std::pair int_pair_copy(10,20); - TRICK_EXPECT_EQ(int_pair, int_pair_copy, test_suite, "int_pair"); - - std::pair< std::string , int > string_first_pair_copy ("string first", 25); - TRICK_EXPECT_EQ(string_first_pair, string_first_pair_copy, test_suite, "string_first_pair"); - - std::pair< int , std::string > string_second_pair_copy (25, "string second"); - TRICK_EXPECT_EQ(string_second_pair_copy, string_second_pair, test_suite, "string_second_pair"); - - std::pair< std::string , std::string > string_pair_copy ("pair first string", "pair second string"); - TRICK_EXPECT_EQ(string_pair_copy, string_pair, test_suite, "string_pair"); - - - std::pair< int , std::pair< int, int > > int_pair_int_int_copy; - int_pair_int_int_copy.first = 200 ; - p.first = 10 ; - p.second = 20 ; - int_pair_int_int_copy.second = p ; - TRICK_EXPECT_EQ(int_pair_int_int_copy, int_pair_int_int, test_suite, "int_pair_int_int"); - - std::pair< std::pair< int, int > , int > pair_int_int_int_copy; - p.first = 15 ; - p.second = 12 ; - pair_int_int_int_copy.first = p ; - pair_int_int_int_copy.second = 180 ; - TRICK_EXPECT_EQ(pair_int_int_int_copy, pair_int_int_int, test_suite, "pair_int_int_int"); - - std::pair< std::pair< int, int > , std::pair< int, int > > pair_pair_pair_copy ; - pair_pair_pair_copy.first.first = 51 ; - pair_pair_pair_copy.first.second = 52 ; - pair_pair_pair_copy.second.first = 53 ; - pair_pair_pair_copy.second.second = 54 ; - TRICK_EXPECT_EQ(pair_pair_pair_copy, pair_pair_pair, test_suite, "pair_pair_pair"); - - // Check all the int/vec combo pairs together, for laziness - TRICK_EXPECT_EQ(int_vec_pair.first, 5, test_suite, "int_vec_pair.first"); - TRICK_EXPECT_EQ(vec_int_pair.second, 5, test_suite, "vec_int_pair.second"); - - TRICK_EXPECT_EQ(int_vec_pair.second.size(), 4, test_suite, "int_vec_pair.second.size"); - TRICK_EXPECT_EQ(vec_int_pair.first.size(), 4, test_suite, "vec_int_pair.first.size"); - TRICK_EXPECT_EQ(vec_vec_pair.first.size(), 4, test_suite, "vec_vec_pair.first.size"); - TRICK_EXPECT_EQ(vec_vec_pair.second.size(), 4, test_suite, "vec_vec_pair.second.size"); - - for (int i = 0; i < int_vec_pair.second.size(); i++) { - TRICK_EXPECT_EQ(int_vec_pair.second[i], (i+1)*5, test_suite, "int_vec_pair.second elems"); - TRICK_EXPECT_EQ(vec_int_pair.first[i], (i+1)*5, test_suite, "vec_int_pair.first elems"); - TRICK_EXPECT_EQ(vec_vec_pair.first[i], (i+1)*5, test_suite, "vec_vec_pair.first elems"); - TRICK_EXPECT_EQ(vec_vec_pair.second[i], (i+1)*5, test_suite, "vec_vec_pair.second elems"); - - } - - - TRICK_EXPECT_EQ(vec_user_simple.size(), 10, test_suite, "vec_user_simple") - for (int i = 0; i < 10; i++) { - for (int j = 0; j < 5; j++) { - TRICK_EXPECT_EQ(vec_user_simple[i].a[j], i+j, test_suite, "vec_user_simple"); - TRICK_EXPECT_EQ(vec_user_simple[i].d->a[j], i+j, test_suite, "vec_user_simple"); - } - - TRICK_EXPECT_EQ(vec_user_simple[i].b, 8888888888, test_suite, "vec_user_simple"); - TRICK_EXPECT_EQ(vec_user_simple[i].d->b, 8888888888, test_suite, "vec_user_simple"); - - TRICK_EXPECT_EQ(vec_user_simple[i].c, "Here is a test string", test_suite, "vec_user_simple"); - TRICK_EXPECT_EQ(vec_user_simple[i].d->c, "Here is a test string", test_suite, "vec_user_simple"); - } - - +int STLCheckpoint::test() { + std::cout << "Running test jobs" << std::endl; + const char *test_suite = "STLCheckpoint"; + + TRICK_EXPECT_EQ( double_vector.size(), 3, test_suite, "double_vector size"); + TRICK_EXPECT_EQ( double_vector[0], 4, test_suite, "double_vector[0]"); + TRICK_EXPECT_EQ( double_vector[1], 5, test_suite, "double_vector[1]"); + TRICK_EXPECT_EQ( double_vector[2], 6, test_suite, "double_vector[2]"); + TRICK_EXPECT_EQ( vector_vector_double[1][0], 103, test_suite, "vector_vector_double[1][0]"); + TRICK_EXPECT_EQ( vector_vector_double[1][1], 104, test_suite, "vector_vector_double[1][1]"); + TRICK_EXPECT_EQ( vector_vector_double[1][2], 105, test_suite, "vector_vector_double[1][2]"); + TRICK_EXPECT_EQ( vector_vector_vector_double[4][2][0], 4006, test_suite, "vector_vector_vector_double[4][2][0]"); + TRICK_EXPECT_EQ( vector_vector_vector_double[4][2][1], 4007, test_suite, "vector_vector_vector_double[4][2][1]"); + TRICK_EXPECT_EQ( vector_vector_vector_double[4][2][2], 4008, test_suite, "vector_vector_vector_double[4][2][2]"); + TRICK_EXPECT_EQ( string_vector[0], std::string("It"), test_suite, "string_vector"); + + TRICK_EXPECT_EQ( double_map[44.4], 444.4, test_suite, "double_map[44.4]" ); + + TRICK_EXPECT_EQ( string_data_map[7], std::string("seiben"), test_suite, "string_data_map[7]" ); + TRICK_EXPECT_EQ( string_data_map[9], std::string("neun") , test_suite, "string_data_map[9]"); + + std::vector< int > v ; + v.push_back(2) ; + v.push_back(4) ; + v.push_back(6) ; + v.push_back(8) ; + TRICK_EXPECT_EQ( map_int_vector_int[1], v, test_suite, "map_int_vector_int[1]"); + + std::pair< int , int > p ; + p.first = 24 ; + p.second = 30 ; + TRICK_EXPECT_EQ(gcd[p], 6, test_suite, "gcd[p]" ); + + p.first = 50 ; + p.second = 60 ; + std::pair< int , int > q ; + q.first = 70 ; + q.second = 80 ; + TRICK_EXPECT_EQ( map_pair_pair[p], q, test_suite, "map_pair_pair[p]" ); + + p.first = 3 ; + p.second = 5 ; + v.clear() ; + v.push_back(15) ; + v.push_back(30) ; + v.push_back(45) ; + v.push_back(60) ; + TRICK_EXPECT_EQ( common_multiples[p], v, test_suite, "common_multiples" ); + + p.first = 3 ; + p.second = 7 ; + v.clear() ; + v.push_back(21) ; + v.push_back(42) ; + v.push_back(84) ; + v.push_back(168) ; + TRICK_EXPECT_EQ( common_multiples[p], v, test_suite, "common_multiples" ); + + + TRICK_EXPECT_EQ( string_map["sister"], "Lisa", test_suite, "string_map[sister]" ); + TRICK_EXPECT_EQ( string_map["dog"], "Santa's Little Helper", test_suite, "string_map[dog]" ); + + + // The easiest way to test the multimaps is to just rebuild copies and compare + std::multimap int_multimap_copy; + int_multimap_copy.insert(std::pair(44,444)) ; + int_multimap_copy.insert(std::pair(55,555)) ; + int_multimap_copy.insert(std::pair(66,666)) ; + int_multimap_copy.insert(std::pair(44,4444)) ; + int_multimap_copy.insert(std::pair(55,5555)) ; + int_multimap_copy.insert(std::pair(66,6666)) ; + TRICK_EXPECT_EQ(int_multimap, int_multimap_copy , test_suite, "int_multimap"); + + int_multimap_copy.insert(std::pair(66,66666)) ; + TRICK_EXPECT_NE(int_multimap, int_multimap_copy , test_suite, "int_multimap_fail"); + + std::multimap string_key_multimap_copy; + string_key_multimap_copy.insert(std::pair("four", 4)) ; + string_key_multimap_copy.insert(std::pair("five", 5)) ; + string_key_multimap_copy.insert(std::pair("six", 6)) ; + string_key_multimap_copy.insert(std::pair("four", 44)) ; + string_key_multimap_copy.insert(std::pair("five", 55)) ; + string_key_multimap_copy.insert(std::pair("six", 66)) ; + TRICK_EXPECT_EQ(string_key_multimap, string_key_multimap_copy , test_suite, "string_key_multimap"); + + std::multimap string_data_multimap_copy; + string_data_multimap_copy.insert(std::pair(7, "seiben")) ; + string_data_multimap_copy.insert(std::pair(8, "acht")) ; + string_data_multimap_copy.insert(std::pair(9, "neun")) ; + string_data_multimap_copy.insert(std::pair(7, "seven")) ; + string_data_multimap_copy.insert(std::pair(8, "eight")) ; + string_data_multimap_copy.insert(std::pair(9, "nine")) ; + TRICK_EXPECT_EQ(string_data_multimap, string_data_multimap_copy , test_suite, "string_data_multimap"); + + std::multimap string_multimap_copy; + string_multimap_copy.insert(std::pair("sister","Lisa")) ; + string_multimap_copy.insert(std::pair("dog","Santa's Little Helper")) ; + string_multimap_copy.insert(std::pair("sister","Meg")) ; + string_multimap_copy.insert(std::pair("dog","Brian")) ; + TRICK_EXPECT_EQ(string_multimap, string_multimap_copy , test_suite, "string_multimap"); + + + // TODO: fix this case + // TRICK_EXPECT_EQ(vec_user_defined.size(), 10, test_suite, "vec_user_defined"); + // for (int i = 0; i < vec_user_defined.size(); i++) { + // TRICK_EXPECT_EQ(vec_user_defined[i].vec.size(), 10, test_suite, "vec_user_defined"); + // TRICK_EXPECT_EQ(vec_user_defined[i].a, 888, test_suite, "vec_user_defined"); + // for (int j = i; j < i+vec_user_defined[i].vec.size(); j++) { + // TRICK_EXPECT_EQ(vec_user_defined[i].vec[j-i], j, test_suite, "vec_user_defined"); + // } + // } + + TRICK_EXPECT_EQ(vec_user_defined_ptr.size(), 10, test_suite, "vec_user_defined_ptr"); + for (int i = 0; i < vec_user_defined_ptr.size(); i++) { + TRICK_EXPECT_EQ(vec_user_defined_ptr[i]->vec.size(), 10, test_suite, "vec_user_defined_ptr"); + TRICK_EXPECT_EQ(vec_user_defined_ptr[i]->a, 888, test_suite, "vec_user_defined_ptr"); + std::vector test_vec; + for (int j = i; j < i+vec_user_defined_ptr[i]->vec.size(); j++) { + test_vec.push_back(j); + } + TRICK_EXPECT_EQ(vec_user_defined_ptr[i]->vec, test_vec, test_suite, "vec_user_defined_ptr"); + } + + + std::vector string_vector_copy = {"It", "has", "the", "Wi-Fies"}; + TRICK_EXPECT_EQ(string_vector, string_vector_copy, test_suite, "string_vector"); + + std::list short_list_copy = {400, 401, 402}; + int list_index = 0; + TRICK_EXPECT_EQ(short_list, short_list_copy, test_suite, "short_list"); + + std::list string_list_copy = {"I", "don't", "care"}; + TRICK_EXPECT_EQ(string_list, string_list_copy, test_suite, "string_list"); + + std::deque float_deque_copy = {98.7, 65.4, 32.1}; + TRICK_EXPECT_EQ(float_deque, float_deque_copy, test_suite, "float_deque"); + + std::deque string_deque_copy = {"Welcome", "to", "PhoneMart"}; + TRICK_EXPECT_EQ(string_deque, string_deque_copy, test_suite, "string_deque"); + + std::set int_set_copy = {8000, 4000, 2000, 1000}; + TRICK_EXPECT_EQ(int_set, int_set_copy, test_suite, "int_set"); + + std::set string_set_copy = {"efg", "abc", "def"}; + TRICK_EXPECT_EQ(string_set, string_set_copy, test_suite, "string_set"); + + std::set> vector_set_copy; + for (int j = 0; j < 5; j++) { + std::vector temp; + for (int i = j; i < 10; i++) { + temp.push_back(i); + } + vector_set_copy.insert(temp); + } + TRICK_EXPECT_EQ(vector_set, vector_set_copy, test_suite, "vector_set"); + + std::set> pair_set_copy; + pair_set_copy.emplace("One", 1); + pair_set_copy.emplace("Two", 2); + pair_set_copy.emplace("Three", 3); + TRICK_EXPECT_EQ(pair_set, pair_set_copy, test_suite, "pair_set"); + + std::set> nested_map_set_copy; + std::map m; + m[5] = 500.5; + m[1] = 100.1; + std::map m2; + m2[5] = 5000.5; + m2[1] = 1000.1; + nested_map_set_copy.insert(m); + nested_map_set_copy.insert(m2); + TRICK_EXPECT_EQ(nested_map_set, nested_map_set_copy, test_suite, "nested_map_set"); + + std::queue> vector_queue_copy; + for (int j = 0; j < 5; j++) { + std::vector temp; + for (int i = j; i < 10; i++) { + temp.push_back(i); + } + vector_queue_copy.push(temp); + } + TRICK_EXPECT_EQ(vector_queue, vector_queue_copy, test_suite, "vector_queue"); + + std::multiset long_multiset_copy = {8000, 4000, 4000, 2000, 1000}; + TRICK_EXPECT_EQ(long_multiset, long_multiset_copy, test_suite, "long_multiset"); + + std::multiset string_multiset_copy = {"efg", "abc", "def", "efg", "abc", "def"}; + TRICK_EXPECT_EQ(string_multiset, string_multiset_copy, test_suite, "string_multiset"); + + std::multiset> pair_multiset_copy; + pair_multiset_copy.emplace(5, 5); + pair_multiset_copy.emplace(5, 5); + pair_multiset_copy.emplace(5, 4); + pair_multiset_copy.emplace(4, 4); + TRICK_EXPECT_EQ(pair_multiset, pair_multiset_copy, test_suite, "pair_multiset"); + + std::multiset> vec_multiset_copy; + vec_multiset_copy.emplace(std::vector({1,2,3,4})); + vec_multiset_copy.emplace(std::vector({1,2,3,4})); + vec_multiset_copy.emplace(std::vector({1,2,3,4,5})); + TRICK_EXPECT_EQ(vec_multiset, vec_multiset_copy, test_suite, "vec_multiset"); + + std::stack uint_stack_copy; + uint_stack_copy.push(1) ; + uint_stack_copy.push(2) ; + uint_stack_copy.push(3) ; + uint_stack_copy.push(4) ; + TRICK_EXPECT_EQ(uint_stack, uint_stack_copy, test_suite, "uint_stack"); + + std::stack string_stack_copy; + string_stack_copy.push("I") ; + string_stack_copy.push("want the one") ; + string_stack_copy.push("with the bigger") ; + string_stack_copy.push("Gee Bees") ; + TRICK_EXPECT_EQ(string_stack, string_stack_copy, test_suite, "string_stack"); + + std::stack> stack_vector_int_copy; + std::vector temp_v1 = {1, 2, 3, 4}; + std::vector temp_v2 = {5, 6, 7, 8}; + stack_vector_int_copy.emplace(temp_v1) ; + stack_vector_int_copy.emplace(temp_v2) ; + TRICK_EXPECT_EQ(stack_vector_int, stack_vector_int_copy, test_suite, "stack_vector_int"); + + std::queue int_queue_copy; + int_queue_copy.push(1) ; + int_queue_copy.push(2) ; + int_queue_copy.push(3) ; + int_queue_copy.push(4) ; + TRICK_EXPECT_EQ(int_queue, int_queue_copy, test_suite, "int_queue"); + + std::queue string_queue_copy; + string_queue_copy.push("I") ; + string_queue_copy.push("want") ; + string_queue_copy.push("an") ; + string_queue_copy.push("iPhone 4") ; + TRICK_EXPECT_EQ(string_queue, string_queue_copy, test_suite, "string_queue"); + + // Why doesn't priority_queue have the == operator but literally everything else does >:( + std::priority_queue int_priority_queue_copy; + int_priority_queue_copy.push(3) ; + int_priority_queue_copy.push(2) ; + int_priority_queue_copy.push(4) ; + int_priority_queue_copy.push(1) ; + compare_data_structures_with_top(int_priority_queue_copy, int_priority_queue, "int_priority_queue"); + + std::priority_queue string_priority_queue_copy; + string_priority_queue_copy.push("I") ; + string_priority_queue_copy.push("want") ; + string_priority_queue_copy.push("an") ; + string_priority_queue_copy.push("iPhone 4") ; + compare_data_structures_with_top(string_priority_queue_copy, string_priority_queue, "string_priority_queue"); + + std::queue> queue_vector_int_copy; + queue_vector_int_copy.emplace(temp_v1) ; + queue_vector_int_copy.emplace(temp_v2) ; + TRICK_EXPECT_EQ(queue_vector_int, queue_vector_int_copy, test_suite, "queue_vector_int"); + + std::priority_queue> priority_queue_vector_int_copy; + priority_queue_vector_int_copy.emplace(temp_v1) ; + priority_queue_vector_int_copy.emplace(temp_v2) ; + compare_data_structures_with_top(priority_queue_vector_int_copy, priority_queue_vector_int, "priority_queue_vector_int"); + + std::pair int_pair_copy(10,20); + TRICK_EXPECT_EQ(int_pair, int_pair_copy, test_suite, "int_pair"); + + std::pair< std::string , int > string_first_pair_copy ("string first", 25); + TRICK_EXPECT_EQ(string_first_pair, string_first_pair_copy, test_suite, "string_first_pair"); + + std::pair< int , std::string > string_second_pair_copy (25, "string second"); + TRICK_EXPECT_EQ(string_second_pair_copy, string_second_pair, test_suite, "string_second_pair"); + + std::pair< std::string , std::string > string_pair_copy ("pair first string", "pair second string"); + TRICK_EXPECT_EQ(string_pair_copy, string_pair, test_suite, "string_pair"); + + + std::pair< int , std::pair< int, int > > int_pair_int_int_copy; + int_pair_int_int_copy.first = 200 ; + p.first = 10 ; + p.second = 20 ; + int_pair_int_int_copy.second = p ; + TRICK_EXPECT_EQ(int_pair_int_int_copy, int_pair_int_int, test_suite, "int_pair_int_int"); + + std::pair< std::pair< int, int > , int > pair_int_int_int_copy; + p.first = 15 ; + p.second = 12 ; + pair_int_int_int_copy.first = p ; + pair_int_int_int_copy.second = 180 ; + TRICK_EXPECT_EQ(pair_int_int_int_copy, pair_int_int_int, test_suite, "pair_int_int_int"); + + std::pair< std::pair< int, int > , std::pair< int, int > > pair_pair_pair_copy ; + pair_pair_pair_copy.first.first = 51 ; + pair_pair_pair_copy.first.second = 52 ; + pair_pair_pair_copy.second.first = 53 ; + pair_pair_pair_copy.second.second = 54 ; + TRICK_EXPECT_EQ(pair_pair_pair_copy, pair_pair_pair, test_suite, "pair_pair_pair"); + + // Check all the int/vec combo pairs together, for laziness + TRICK_EXPECT_EQ(int_vec_pair.first, 5, test_suite, "int_vec_pair.first"); + TRICK_EXPECT_EQ(vec_int_pair.second, 5, test_suite, "vec_int_pair.second"); + + TRICK_EXPECT_EQ(int_vec_pair.second.size(), 4, test_suite, "int_vec_pair.second.size"); + TRICK_EXPECT_EQ(vec_int_pair.first.size(), 4, test_suite, "vec_int_pair.first.size"); + TRICK_EXPECT_EQ(vec_vec_pair.first.size(), 4, test_suite, "vec_vec_pair.first.size"); + TRICK_EXPECT_EQ(vec_vec_pair.second.size(), 4, test_suite, "vec_vec_pair.second.size"); + + for (int i = 0; i < int_vec_pair.second.size(); i++) { + TRICK_EXPECT_EQ(int_vec_pair.second[i], (i+1)*5, test_suite, "int_vec_pair.second elems"); + TRICK_EXPECT_EQ(vec_int_pair.first[i], (i+1)*5, test_suite, "vec_int_pair.first elems"); + TRICK_EXPECT_EQ(vec_vec_pair.first[i], (i+1)*5, test_suite, "vec_vec_pair.first elems"); + TRICK_EXPECT_EQ(vec_vec_pair.second[i], (i+1)*5, test_suite, "vec_vec_pair.second elems"); + + } + + + TRICK_EXPECT_EQ(vec_user_simple.size(), 10, test_suite, "vec_user_simple") + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 5; j++) { + TRICK_EXPECT_EQ(vec_user_simple[i].a[j], i+j, test_suite, "vec_user_simple"); + TRICK_EXPECT_EQ(vec_user_simple[i].d->a[j], i+j, test_suite, "vec_user_simple"); + } + + TRICK_EXPECT_EQ(vec_user_simple[i].b, 8888888888, test_suite, "vec_user_simple"); + TRICK_EXPECT_EQ(vec_user_simple[i].d->b, 8888888888, test_suite, "vec_user_simple"); + + TRICK_EXPECT_EQ(vec_user_simple[i].c, "Here is a test string", test_suite, "vec_user_simple"); + TRICK_EXPECT_EQ(vec_user_simple[i].d->c, "Here is a test string", test_suite, "vec_user_simple"); + } + + } diff --git a/test/SIM_target_specific_variables/models/many/a.cpp b/test/SIM_target_specific_variables/models/many/a.cpp index b23abf618..6b61dd292 100644 --- a/test/SIM_target_specific_variables/models/many/a.cpp +++ b/test/SIM_target_specific_variables/models/many/a.cpp @@ -1 +1 @@ -/* /* */ +/* /* */ diff --git a/test/SIM_target_specific_variables/models/many/b.cpp b/test/SIM_target_specific_variables/models/many/b.cpp index b23abf618..6b61dd292 100644 --- a/test/SIM_target_specific_variables/models/many/b.cpp +++ b/test/SIM_target_specific_variables/models/many/b.cpp @@ -1 +1 @@ -/* /* */ +/* /* */ diff --git a/test/SIM_target_specific_variables/models/many/c.cpp b/test/SIM_target_specific_variables/models/many/c.cpp index b23abf618..6b61dd292 100644 --- a/test/SIM_target_specific_variables/models/many/c.cpp +++ b/test/SIM_target_specific_variables/models/many/c.cpp @@ -1 +1 @@ -/* /* */ +/* /* */ diff --git a/test/SIM_target_specific_variables/models/nested/x.cpp b/test/SIM_target_specific_variables/models/nested/x.cpp index b23abf618..6b61dd292 100644 --- a/test/SIM_target_specific_variables/models/nested/x.cpp +++ b/test/SIM_target_specific_variables/models/nested/x.cpp @@ -1 +1 @@ -/* /* */ +/* /* */ diff --git a/test/SIM_target_specific_variables/models/nested/y/y.cpp b/test/SIM_target_specific_variables/models/nested/y/y.cpp index b23abf618..6b61dd292 100644 --- a/test/SIM_target_specific_variables/models/nested/y/y.cpp +++ b/test/SIM_target_specific_variables/models/nested/y/y.cpp @@ -1 +1 @@ -/* /* */ +/* /* */ diff --git a/test/SIM_target_specific_variables/models/nested/z/z.cpp b/test/SIM_target_specific_variables/models/nested/z/z.cpp index b23abf618..6b61dd292 100644 --- a/test/SIM_target_specific_variables/models/nested/z/z.cpp +++ b/test/SIM_target_specific_variables/models/nested/z/z.cpp @@ -1 +1 @@ -/* /* */ +/* /* */ diff --git a/test/SIM_target_specific_variables/models/one/1.cpp b/test/SIM_target_specific_variables/models/one/1.cpp index b23abf618..6b61dd292 100644 --- a/test/SIM_target_specific_variables/models/one/1.cpp +++ b/test/SIM_target_specific_variables/models/one/1.cpp @@ -1 +1 @@ -/* /* */ +/* /* */ diff --git a/test/SIM_test_dr/models/dr/src/DR.cpp b/test/SIM_test_dr/models/dr/src/DR.cpp index 0a68d7264..aa7adbacd 100644 --- a/test/SIM_test_dr/models/dr/src/DR.cpp +++ b/test/SIM_test_dr/models/dr/src/DR.cpp @@ -1,14 +1,14 @@ -/******************************TRICK HEADER************************************* -PURPOSE: ( Test data record ) -REFERENCE: ( None ) -ASSUMPTIONS AND LIMITATIONS: ( None ) -CLASS: ( scheduled ) -LIBRARY DEPENDENCY: ( DR.o ) -PROGRAMMERS: ( (Lindsay Landry) (L3) (7-22-2013) ) +/******************************TRICK HEADER************************************* +PURPOSE: ( Test data record ) +REFERENCE: ( None ) +ASSUMPTIONS AND LIMITATIONS: ( None ) +CLASS: ( scheduled ) +LIBRARY DEPENDENCY: ( DR.o ) +PROGRAMMERS: ( (Lindsay Landry) (L3) (7-22-2013) ) *******************************************************************************/ -#include -#include "../include/DR.hh" +#include +#include "../include/DR.hh" -DRTypes::DRTypes() {} -DRTypes::~DRTypes() {} +DRTypes::DRTypes() {} +DRTypes::~DRTypes() {} diff --git a/test/SIM_test_dr/models/dr/src/DR_default_data.cpp b/test/SIM_test_dr/models/dr/src/DR_default_data.cpp index 38ac316be..5e655b951 100644 --- a/test/SIM_test_dr/models/dr/src/DR_default_data.cpp +++ b/test/SIM_test_dr/models/dr/src/DR_default_data.cpp @@ -1,104 +1,104 @@ -/******************************TRICK HEADER************************************* -PURPOSE: ( Test data record ) -REFERENCE: ( None ) -ASSUMPTIONS AND LIMITATIONS: ( None ) -CLASS: ( scheduled ) -LIBRARY DEPENDENCY: ( DR.o ) -PROGRAMMERS: ( (Lindsay Landry) (L3) (7-22-2013) ) +/******************************TRICK HEADER************************************* +PURPOSE: ( Test data record ) +REFERENCE: ( None ) +ASSUMPTIONS AND LIMITATIONS: ( None ) +CLASS: ( scheduled ) +LIBRARY DEPENDENCY: ( DR.o ) +PROGRAMMERS: ( (Lindsay Landry) (L3) (7-22-2013) ) *******************************************************************************/ -#include "../include/DR.hh" +#include "../include/DR.hh" -int DRTypes::init() { +int DRTypes::init() { - a = 'a'; //char - b = 'b'; //unsigned char - c = -1234; //short - d = 1234; //unsigned short - e = -123456; //int - f = 123456; //unsigned int - g = -1234567; //long - h = 123456789; //unsigned long - i = 1234.5678; //float - j = -1234.567890; //double - k = -12345678912345;//long long - l = 12345678912345; //unsigned long - m = false; //boolean - n = THREE; //enumerated type - o = "3 May. Bistritz.—Left Munich at 8:35 P. M., on 1st May, arriving at Vienna early next morning; should have arrived at 6:46, but train was an hour late. Buda-Pesth seems a wonderful place, from the glimpse which I got of it from the train and the little I could walk through the streets. I feared to go very far from the station, as we had arrived late and would start as near the correct time as possible. The impression I had was that we were leaving the West and entering the East; the most western of splendid bridges over the Danube, which is here of noble width and depth, took us among the traditions of Turkish rule."; - p = "We left in pretty good time, and came after nightfall to Klausenburgh. Here I stopped for the night at the Hotel Royale. I had for dinner, or rather supper, a chicken done up some way with red pepper, which was very good but thirsty. (Mem., get recipe for Mina.) I asked the waiter, and he said it was called “paprika hendl,” and that, as it was a national dish, I should be able to get it anywhere along the Carpathians. I found my smattering of German very useful here; indeed, I don't know how I should be able to get on without it."; - for (int i = 0; i < 5; i++) { - q[i] = i; + a = 'a'; //char + b = 'b'; //unsigned char + c = -1234; //short + d = 1234; //unsigned short + e = -123456; //int + f = 123456; //unsigned int + g = -1234567; //long + h = 123456789; //unsigned long + i = 1234.5678; //float + j = -1234.567890; //double + k = -12345678912345;//long long + l = 12345678912345; //unsigned long + m = false; //boolean + n = THREE; //enumerated type + o = "3 May. Bistritz.—Left Munich at 8:35 P. M., on 1st May, arriving at Vienna early next morning; should have arrived at 6:46, but train was an hour late. Buda-Pesth seems a wonderful place, from the glimpse which I got of it from the train and the little I could walk through the streets. I feared to go very far from the station, as we had arrived late and would start as near the correct time as possible. The impression I had was that we were leaving the West and entering the East; the most western of splendid bridges over the Danube, which is here of noble width and depth, took us among the traditions of Turkish rule."; + p = "We left in pretty good time, and came after nightfall to Klausenburgh. Here I stopped for the night at the Hotel Royale. I had for dinner, or rather supper, a chicken done up some way with red pepper, which was very good but thirsty. (Mem., get recipe for Mina.) I asked the waiter, and he said it was called “paprika hendl,” and that, as it was a national dish, I should be able to get it anywhere along the Carpathians. I found my smattering of German very useful here; indeed, I don't know how I should be able to get on without it."; + for (int i = 0; i < 5; i++) { + q[i] = i; } - r[0][0] = 10; - r[0][1] = 20; - r[1][0] = 30; - r[1][1] = 40; + r[0][0] = 10; + r[0][1] = 20; + r[1][0] = 30; + r[1][1] = 40; /*============================================================================ - Bitfields - ============================================================================ + Bitfields + ============================================================================ UNSIGNED - var1: Larger value than will fit - var2: Min value - var3: Middle value - var4: Max value + var1: Larger value than will fit + var2: Min value + var3: Middle value + var4: Max value */ - /* Unsigned Int */ - //14 5 12 1 - uintB.var1 = (1 << 14) + (1 << 14/2); - uintB.var2 = 0; - uintB.var3 = (1 << 12/2) - 1; - uintB.var4 = (1 << 1) - 1; + /* Unsigned Int */ + //14 5 12 1 + uintB.var1 = (1 << 14) + (1 << 14/2); + uintB.var2 = 0; + uintB.var3 = (1 << 12/2) - 1; + uintB.var4 = (1 << 1) - 1; - /* Unsigned Char */ - // 3 2 2 1 - ucharB.var1 = (1 << 3) + (1 << 3/2); - ucharB.var2 = 0; - ucharB.var3 = (1 << 2/2) - 1; - ucharB.var4 = (1 << 1) - 1; + /* Unsigned Char */ + // 3 2 2 1 + ucharB.var1 = (1 << 3) + (1 << 3/2); + ucharB.var2 = 0; + ucharB.var3 = (1 << 2/2) - 1; + ucharB.var4 = (1 << 1) - 1; - /* Unsigned Short */ - // 4 2 9 1 - ushortB.var1 = (1 << 4) + (1 << 4/2); - ushortB.var2 = 0; - ushortB.var3 = (1 << 9/2) - 1; - ushortB.var4 = (1 << 1) - 1; + /* Unsigned Short */ + // 4 2 9 1 + ushortB.var1 = (1 << 4) + (1 << 4/2); + ushortB.var2 = 0; + ushortB.var3 = (1 << 9/2) - 1; + ushortB.var4 = (1 << 1) - 1; /* SIGNED - var1: Max positive value - var2: Max negative value - var3: Zero - var4: Too large value -> negative + var1: Max positive value + var2: Max negative value + var3: Zero + var4: Too large value -> negative */ - /* Int */ - // 7 16 3 6 - intB.var1 = (1 << (7 - 1)) - 1; - intB.var2 = -(1 << (16 - 1)); - intB.var3 = 0; - intB.var4 = (1 << (6 - 1)) + (1 << 6/2);; + /* Int */ + // 7 16 3 6 + intB.var1 = (1 << (7 - 1)) - 1; + intB.var2 = -(1 << (16 - 1)); + intB.var3 = 0; + intB.var4 = (1 << (6 - 1)) + (1 << 6/2);; - /* Char */ - // 2 2 2 2 - charB.var1 = (1 << (2 - 1)) - 1; - charB.var2 = -(1 << (2 - 1)); - charB.var3 = 0; - charB.var4 = (1 << (2 - 1)) + (1 << 2/2);; + /* Char */ + // 2 2 2 2 + charB.var1 = (1 << (2 - 1)) - 1; + charB.var2 = -(1 << (2 - 1)); + charB.var3 = 0; + charB.var4 = (1 << (2 - 1)) + (1 << 2/2);; - /* Short */ - // 8 1 2 5 - shortB.var1 = (1 << (8 - 1)) - 1; - shortB.var2 = -(1 << (1 - 1)); - shortB.var3 = 0; - shortB.var4 = (1 << (5 - 1)) + (1 << 5/2);; + /* Short */ + // 8 1 2 5 + shortB.var1 = (1 << (8 - 1)) - 1; + shortB.var2 = -(1 << (1 - 1)); + shortB.var3 = 0; + shortB.var4 = (1 << (5 - 1)) + (1 << 5/2);; - /* Mixed Types */ - // 3 8 9 12 - mixB.var1 = (1 << (3 - 1)) - 1; - mixB.var2 = -(1 << (8 - 1)); - mixB.var3 = 0; - mixB.var4 = (1 << (12 - 1)) + (1 << 12/2);; + /* Mixed Types */ + // 3 8 9 12 + mixB.var1 = (1 << (3 - 1)) - 1; + mixB.var2 = -(1 << (8 - 1)); + mixB.var3 = 0; + mixB.var4 = (1 << (12 - 1)) + (1 << 12/2);; - return (0); + return (0); } diff --git a/test/SIM_test_ip/models/test_ip/src/ClassOfEverything.cpp b/test/SIM_test_ip/models/test_ip/src/ClassOfEverything.cpp index cfd352e1b..cbb4c2944 100644 --- a/test/SIM_test_ip/models/test_ip/src/ClassOfEverything.cpp +++ b/test/SIM_test_ip/models/test_ip/src/ClassOfEverything.cpp @@ -1,21 +1,21 @@ -#include "test_ip/include/ClassOfEverything.hh" +#include "test_ip/include/ClassOfEverything.hh" -double ClassOfEverything::sdaa[3][3] ; -const double ClassOfEverything::scd = 1.2345 ; -const double ClassOfEverything::csd = 6.7890 ; -const double ClassOfEverything::sdc = 9.8765 ; +double ClassOfEverything::sdaa[3][3] ; +const double ClassOfEverything::scd = 1.2345 ; +const double ClassOfEverything::csd = 6.7890 ; +const double ClassOfEverything::sdc = 9.8765 ; -ClassOfEverything::ClassOfEverything() : cir(i), icr(i) { +ClassOfEverything::ClassOfEverything() : cir(i), icr(i) { - unsigned int ii ; + unsigned int ii ; - ep = NULL ; - epp = NULL ; + ep = NULL ; + epp = NULL ; - for ( ii = 0 ; ii < 4 ; ii++ ) { - eap[ii] = NULL ; - } + for ( ii = 0 ; ii < 4 ; ii++ ) { + eap[ii] = NULL ; + } } diff --git a/test/SIM_test_output_dir/models/starter.cpp b/test/SIM_test_output_dir/models/starter.cpp index 30809e266..c2f10c748 100644 --- a/test/SIM_test_output_dir/models/starter.cpp +++ b/test/SIM_test_output_dir/models/starter.cpp @@ -1,66 +1,66 @@ -#include -#include "starter.h" -#include "trick/integrator_c_intf.h" -#include "trick/exec_proto.h" -#include "trick/message_proto.h" -#include "trick/mm_macros.hh" +#include +#include "starter.h" +#include "trick/integrator_c_intf.h" +#include "trick/exec_proto.h" +#include "trick/message_proto.h" +#include "trick/mm_macros.hh" -Starter::Starter() { +Starter::Starter() { } -int Starter::default_data() { - // Allocate a dynamic object - DynamicObj * obj = new DynamicObj() ; - obj->a = 5; - obj->b = "Hello world!"; - obj->c = (double *) malloc (sizeof(double) * 3); - obj->c[0] = 0.0; - obj->c[1] = 1.0; - obj->c[2] = 2.0; +int Starter::default_data() { + // Allocate a dynamic object + DynamicObj * obj = new DynamicObj() ; + obj->a = 5; + obj->b = "Hello world!"; + obj->c = (double *) malloc (sizeof(double) * 3); + obj->c[0] = 0.0; + obj->c[1] = 1.0; + obj->c[2] = 2.0; - TMM_declare_ext_var(obj, TRICK_STRUCTURED,"DynamicObj", 0, "DynamicObj_alloc", 0, NULL) ; + TMM_declare_ext_var(obj, TRICK_STRUCTURED,"DynamicObj", 0, "DynamicObj_alloc", 0, NULL) ; - return 0; + return 0; } -int Starter::init() { - return 0; +int Starter::init() { + return 0; } -int Starter::scheduled() { - message_publish(MSG_NORMAL, "Hello World!\n"); - return 0; +int Starter::scheduled() { + message_publish(MSG_NORMAL, "Hello World!\n"); + return 0; } -int Starter::deriv() { - return 0; +int Starter::deriv() { + return 0; } -int Starter::integ() { +int Starter::integ() { - int ipass; - load_state( - NULL /* list is NULL terminated */ - ); + int ipass; + load_state( + NULL /* list is NULL terminated */ + ); - /* LOAD THE POSITION AND VELOCITY STATE DERIVATIVES */ - load_deriv( - NULL /* list is NULL terminated */ - ); + /* LOAD THE POSITION AND VELOCITY STATE DERIVATIVES */ + load_deriv( + NULL /* list is NULL terminated */ + ); - /* Call the Trick integrate service */ - ipass = integrate(); + /* Call the Trick integrate service */ + ipass = integrate(); - /* unload new state */ - unload_state( - NULL /* list is NULL terminated */ - ); + /* unload new state */ + unload_state( + NULL /* list is NULL terminated */ + ); - /* returns 0 if integerate() was successful */ - return ipass; + /* returns 0 if integerate() was successful */ + return ipass; } -int Starter::shutdown() { - return 0; +int Starter::shutdown() { + return 0; } diff --git a/test/SIM_test_varserv/models/test_client/test_client.cpp b/test/SIM_test_varserv/models/test_client/test_client.cpp index fc36f7134..6430c1e1b 100644 --- a/test/SIM_test_varserv/models/test_client/test_client.cpp +++ b/test/SIM_test_varserv/models/test_client/test_client.cpp @@ -1,1565 +1,1565 @@ -#include "test_client.hh" -#include "trick/var_binary_parser.hh" -#include - - -class VariableServerUDPTest : public ::testing::Test { - protected: - VariableServerUDPTest() { - socket_status = socket.init("localhost", 48000, SOCK_DGRAM); - - if (socket_status == 0) { - std::stringstream request; - request << "trick.var_set_client_tag(\"UDP_VSTest"; - request << numSession++; - request << "\") \n"; - - socket << request.str(); - } - } - ~VariableServerUDPTest() { - socket.close(); - } - - Socket socket; - int socket_status; - - static int numSession; +#include "test_client.hh" +#include "trick/var_binary_parser.hh" +#include + + +class VariableServerUDPTest : public ::testing::Test { + protected: + VariableServerUDPTest() { + socket_status = socket.init("localhost", 48000, SOCK_DGRAM); + + if (socket_status == 0) { + std::stringstream request; + request << "trick.var_set_client_tag(\"UDP_VSTest"; + request << numSession++; + request << "\") \n"; + + socket << request.str(); + } + } + ~VariableServerUDPTest() { + socket.close(); + } + + Socket socket; + int socket_status; + + static int numSession; }; -class VariableServerTestAltListener : public ::testing::Test { - protected: - VariableServerTestAltListener() { - socket_status = socket.init("localhost", 49000); - - if (socket_status == 0) { - std::stringstream request; - request << "trick.var_set_client_tag(\"altListener_VSTest"; - request << numSession++; - request << "\") \n"; - - socket << request.str(); - } - } - ~VariableServerTestAltListener() { - socket << "trick.var_exit()\n"; - socket.close(); - } - - Socket socket; - int socket_status; - - static int numSession; +class VariableServerTestAltListener : public ::testing::Test { + protected: + VariableServerTestAltListener() { + socket_status = socket.init("localhost", 49000); + + if (socket_status == 0) { + std::stringstream request; + request << "trick.var_set_client_tag(\"altListener_VSTest"; + request << numSession++; + request << "\") \n"; + + socket << request.str(); + } + } + ~VariableServerTestAltListener() { + socket << "trick.var_exit()\n"; + socket.close(); + } + + Socket socket; + int socket_status; + + static int numSession; }; -int VariableServerTest::numSession = 0; -int VariableServerUDPTest::numSession = 0; -int VariableServerTestAltListener::numSession = 0; - -#ifndef __APPLE__ -class VariableServerTestMulticast : public ::testing::Test { - protected: - VariableServerTestMulticast() { - socket_status = socket.init("", 47000, SOCK_DGRAM); - socket_status = multicast_listener.init_multicast("224.10.10.10", 47000); - - if (socket_status == 0) { - std::stringstream request; - request << "trick.var_set_client_tag(\"multicast_VSTest"; - request << numSession++; - request << "\") \n"; - - socket << request.str(); - } - } - ~VariableServerTestMulticast() { - socket.close(); - multicast_listener.close(); - } - - Socket socket; - Socket multicast_listener; - - int socket_status; - - static int numSession; +int VariableServerTest::numSession = 0; +int VariableServerUDPTest::numSession = 0; +int VariableServerTestAltListener::numSession = 0; + +#ifndef __APPLE__ +class VariableServerTestMulticast : public ::testing::Test { + protected: + VariableServerTestMulticast() { + socket_status = socket.init("", 47000, SOCK_DGRAM); + socket_status = multicast_listener.init_multicast("224.10.10.10", 47000); + + if (socket_status == 0) { + std::stringstream request; + request << "trick.var_set_client_tag(\"multicast_VSTest"; + request << numSession++; + request << "\") \n"; + + socket << request.str(); + } + } + ~VariableServerTestMulticast() { + socket.close(); + multicast_listener.close(); + } + + Socket socket; + Socket multicast_listener; + + int socket_status; + + static int numSession; }; -int VariableServerTestMulticast::numSession = 0; +int VariableServerTestMulticast::numSession = 0; #endif /**********************************************************/ -/* Helpful constants and functions */ +/* Helpful constants and functions */ /**********************************************************/ -const int MODE_RUN = 5; -const int MODE_FREEZE = 1; - -int strcmp_IgnoringWhiteSpace(std::string s1_str, std::string s2_str) { - const char * s1 = s1_str.c_str(); - const char * s2 = s2_str.c_str(); - - int i1 = 0; - int i2 = 0; - - while (1) { - while ( !isgraph( s1[i1] ) && s1[i1] != '\0') { i1++; } - while ( !isgraph( s2[i2] ) && s2[i2] != '\0') { i2++; } - if ( s1[i1] == '\0' && s2[i2] == '\0') { return 0; } - if ( s1[i1] != s2[i2]) { - if (s1[i1] < s2[i2]) { - return -1; - } else { - return 1; - } - } - i1++; i2++; - } +const int MODE_RUN = 5; +const int MODE_FREEZE = 1; + +int strcmp_IgnoringWhiteSpace(std::string s1_str, std::string s2_str) { + const char * s1 = s1_str.c_str(); + const char * s2 = s2_str.c_str(); + + int i1 = 0; + int i2 = 0; + + while (1) { + while ( !isgraph( s1[i1] ) && s1[i1] != '\0') { i1++; } + while ( !isgraph( s2[i2] ) && s2[i2] != '\0') { i2++; } + if ( s1[i1] == '\0' && s2[i2] == '\0') { return 0; } + if ( s1[i1] != s2[i2]) { + if (s1[i1] < s2[i2]) { + return -1; + } else { + return 1; + } + } + i1++; i2++; + } } -void spin (Socket& socket, int wait_cycles = 5) { - for (int i = 0; i < wait_cycles; i++) - socket.receive(); +void spin (Socket& socket, int wait_cycles = 5) { + for (int i = 0; i < wait_cycles; i++) + socket.receive(); } -void wait_for_mode_change (Socket& socket, int expected_mode, int max_wait_iterations = 10) { - int iteration = 0; - std::string mode_reply; - std::string expected_reply = "5\t" + std::to_string(expected_mode) + "\n"; - while (iteration++ < max_wait_iterations) { - socket << "trick.var_send_once(\"trick_sys.sched.mode\")\n"; - socket >> mode_reply; - if (mode_reply == expected_reply) - break; - } +void wait_for_mode_change (Socket& socket, int expected_mode, int max_wait_iterations = 10) { + int iteration = 0; + std::string mode_reply; + std::string expected_reply = "5\t" + std::to_string(expected_mode) + "\n"; + while (iteration++ < max_wait_iterations) { + socket << "trick.var_send_once(\"trick_sys.sched.mode\")\n"; + socket >> mode_reply; + if (mode_reply == expected_reply) + break; + } } -void dump_checkpoint (Socket& socket, const std::string& checkpoint_name) { - socket << "trick.var_pause()\ntrick.exec_freeze()\n"; - wait_for_mode_change(socket, MODE_FREEZE); +void dump_checkpoint (Socket& socket, const std::string& checkpoint_name) { + socket << "trick.var_pause()\ntrick.exec_freeze()\n"; + wait_for_mode_change(socket, MODE_FREEZE); - std::string checkpoint_cmd = "trick.checkpoint(\"" + checkpoint_name + "\")\n"; - socket << checkpoint_cmd; + std::string checkpoint_cmd = "trick.checkpoint(\"" + checkpoint_name + "\")\n"; + socket << checkpoint_cmd; - socket << "trick.exec_run()\n"; - wait_for_mode_change(socket, MODE_RUN); - socket << "trick.var_unpause()\n"; + socket << "trick.exec_run()\n"; + wait_for_mode_change(socket, MODE_RUN); + socket << "trick.var_unpause()\n"; } -void load_checkpoint (Socket& socket, const std::string& checkpoint_name) { - socket << "trick.var_pause()\ntrick.exec_freeze()\n"; - wait_for_mode_change(socket, MODE_FREEZE); +void load_checkpoint (Socket& socket, const std::string& checkpoint_name) { + socket << "trick.var_pause()\ntrick.exec_freeze()\n"; + wait_for_mode_change(socket, MODE_FREEZE); - std::string checkpoint_cmd = "trick.load_checkpoint(\"" + checkpoint_name + "\")\n"; - socket << checkpoint_cmd; - sleep(5); + std::string checkpoint_cmd = "trick.load_checkpoint(\"" + checkpoint_name + "\")\n"; + socket << checkpoint_cmd; + sleep(5); - socket << "trick.exec_run()\n"; - wait_for_mode_change(socket, MODE_RUN); - socket << "trick.var_unpause()\n"; + socket << "trick.exec_run()\n"; + wait_for_mode_change(socket, MODE_RUN); + socket << "trick.var_unpause()\n"; } /*****************************************/ -/* Multicast Test */ +/* Multicast Test */ /*****************************************/ -#ifndef __APPLE__ +#ifndef __APPLE__ -TEST_F (VariableServerTestMulticast, Strings) { - if (socket_status != 0) { - FAIL(); - } +TEST_F (VariableServerTestMulticast, Strings) { + if (socket_status != 0) { + FAIL(); + } - std::string reply; - socket << "trick.var_send_once(\"vsx.vst.o\")\n"; - std::string expected("5\tYou will rejoice to hear that no disaster has accompanied the commencement of an enterprise which you have regarded with such evil forebodings. I arrived here yesterday, and my first task is to assure my dear sister of my welfare and increasing confidence in the success of my undertaking."); + std::string reply; + socket << "trick.var_send_once(\"vsx.vst.o\")\n"; + std::string expected("5\tYou will rejoice to hear that no disaster has accompanied the commencement of an enterprise which you have regarded with such evil forebodings. I arrived here yesterday, and my first task is to assure my dear sister of my welfare and increasing confidence in the success of my undertaking."); - multicast_listener >> reply; + multicast_listener >> reply; - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - expected = std::string("5\tI am already far north of London, and as I walk in the streets of Petersburgh, I feel a cold northern breeze play upon my cheeks, which braces my nerves and fills me with delight. Do you understand this feeling?"); - socket << "trick.var_send_once(\"vsx.vst.p\")\n"; + expected = std::string("5\tI am already far north of London, and as I walk in the streets of Petersburgh, I feel a cold northern breeze play upon my cheeks, which braces my nerves and fills me with delight. Do you understand this feeling?"); + socket << "trick.var_send_once(\"vsx.vst.p\")\n"; - multicast_listener >> reply; + multicast_listener >> reply; - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); } -TEST_F (VariableServerTestMulticast, AddRemove) { - if (socket_status != 0) { - FAIL(); - } - - std::string reply; - std::string expected; - - int max_tries = 3; - int tries = 0; - - socket << "trick.var_add(\"vsx.vst.c\")\n"; - multicast_listener >> reply; - expected = std::string("0 -1234"); - - tries = 0; - while (strcmp_IgnoringWhiteSpace(reply, expected) != 0 && tries++ < max_tries) { - multicast_listener >> reply; - } - - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0) << "Expected: " << expected << "\tAcutal: " << reply; - - multicast_listener >> reply; - tries = 0; - while (strcmp_IgnoringWhiteSpace(reply, expected) != 0 && tries++ < max_tries) { - multicast_listener >> reply; - } - - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0) << "Expected: " << expected << "\tAcutal: " << reply; - - socket << "trick.var_add(\"vsx.vst.m\")\n"; - multicast_listener >> reply; - expected = std::string("0 -1234 1"); - tries = 0; - while (strcmp_IgnoringWhiteSpace(reply, expected) != 0 && tries++ < max_tries) { - multicast_listener >> reply; - } - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0) << "Expected: " << expected << "\tAcutal: " << reply; - - socket << "trick.var_remove(\"vsx.vst.m\")\n"; - multicast_listener >> reply; - expected = std::string("0 -1234"); - tries = 0; - while (strcmp_IgnoringWhiteSpace(reply, expected) != 0 && tries++ < max_tries) { - multicast_listener >> reply; - } - - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0) << "Expected: " << expected << "\tAcutal: " << reply; - - socket << "trick.var_add(\"vsx.vst.n\")\n"; - multicast_listener >> reply; - expected = std::string("0 -1234 0,1,2,3,4"); - tries = 0; - while (strcmp_IgnoringWhiteSpace(reply, expected) != 0 && tries++ < max_tries) { - multicast_listener >> reply; - } - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0) << "Expected: " << expected << "\tAcutal: " << reply; - - socket << "trick.var_exit()\n"; +TEST_F (VariableServerTestMulticast, AddRemove) { + if (socket_status != 0) { + FAIL(); + } + + std::string reply; + std::string expected; + + int max_tries = 3; + int tries = 0; + + socket << "trick.var_add(\"vsx.vst.c\")\n"; + multicast_listener >> reply; + expected = std::string("0 -1234"); + + tries = 0; + while (strcmp_IgnoringWhiteSpace(reply, expected) != 0 && tries++ < max_tries) { + multicast_listener >> reply; + } + + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0) << "Expected: " << expected << "\tAcutal: " << reply; + + multicast_listener >> reply; + tries = 0; + while (strcmp_IgnoringWhiteSpace(reply, expected) != 0 && tries++ < max_tries) { + multicast_listener >> reply; + } + + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0) << "Expected: " << expected << "\tAcutal: " << reply; + + socket << "trick.var_add(\"vsx.vst.m\")\n"; + multicast_listener >> reply; + expected = std::string("0 -1234 1"); + tries = 0; + while (strcmp_IgnoringWhiteSpace(reply, expected) != 0 && tries++ < max_tries) { + multicast_listener >> reply; + } + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0) << "Expected: " << expected << "\tAcutal: " << reply; + + socket << "trick.var_remove(\"vsx.vst.m\")\n"; + multicast_listener >> reply; + expected = std::string("0 -1234"); + tries = 0; + while (strcmp_IgnoringWhiteSpace(reply, expected) != 0 && tries++ < max_tries) { + multicast_listener >> reply; + } + + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0) << "Expected: " << expected << "\tAcutal: " << reply; + + socket << "trick.var_add(\"vsx.vst.n\")\n"; + multicast_listener >> reply; + expected = std::string("0 -1234 0,1,2,3,4"); + tries = 0; + while (strcmp_IgnoringWhiteSpace(reply, expected) != 0 && tries++ < max_tries) { + multicast_listener >> reply; + } + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0) << "Expected: " << expected << "\tAcutal: " << reply; + + socket << "trick.var_exit()\n"; } #endif /************************************/ -/* UDP Tests */ +/* UDP Tests */ /************************************/ -TEST_F (VariableServerUDPTest, Strings) { - if (socket_status != 0) { - FAIL(); - } +TEST_F (VariableServerUDPTest, Strings) { + if (socket_status != 0) { + FAIL(); + } - std::string reply; - socket << "trick.var_send_once(\"vsx.vst.o\")\n"; - socket >> reply; - std::string expected("5\tYou will rejoice to hear that no disaster has accompanied the commencement of an enterprise which you have regarded with such evil forebodings. I arrived here yesterday, and my first task is to assure my dear sister of my welfare and increasing confidence in the success of my undertaking."); + std::string reply; + socket << "trick.var_send_once(\"vsx.vst.o\")\n"; + socket >> reply; + std::string expected("5\tYou will rejoice to hear that no disaster has accompanied the commencement of an enterprise which you have regarded with such evil forebodings. I arrived here yesterday, and my first task is to assure my dear sister of my welfare and increasing confidence in the success of my undertaking."); - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - expected = std::string("5\tI am already far north of London, and as I walk in the streets of Petersburgh, I feel a cold northern breeze play upon my cheeks, which braces my nerves and fills me with delight. Do you understand this feeling?"); - socket << "trick.var_send_once(\"vsx.vst.p\")\n"; + expected = std::string("5\tI am already far north of London, and as I walk in the streets of Petersburgh, I feel a cold northern breeze play upon my cheeks, which braces my nerves and fills me with delight. Do you understand this feeling?"); + socket << "trick.var_send_once(\"vsx.vst.p\")\n"; - socket >> reply; + socket >> reply; - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); } -TEST_F (VariableServerUDPTest, AddRemove) { - if (socket_status != 0) { - FAIL(); - } +TEST_F (VariableServerUDPTest, AddRemove) { + if (socket_status != 0) { + FAIL(); + } - std::string reply; - std::string expected; + std::string reply; + std::string expected; - socket << "trick.var_add(\"vsx.vst.c\")\n"; - socket >> reply; - expected = std::string("0 -1234"); + socket << "trick.var_add(\"vsx.vst.c\")\n"; + socket >> reply; + expected = std::string("0 -1234"); - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - socket >> reply; + socket >> reply; - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - socket << "trick.var_add(\"vsx.vst.m\")\n"; - socket >> reply; - expected = std::string("0 -1234 1"); - - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + socket << "trick.var_add(\"vsx.vst.m\")\n"; + socket >> reply; + expected = std::string("0 -1234 1"); + + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - socket << "trick.var_remove(\"vsx.vst.m\")\n"; - socket >> reply; - expected = std::string("0 -1234"); - - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + socket << "trick.var_remove(\"vsx.vst.m\")\n"; + socket >> reply; + expected = std::string("0 -1234"); + + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - socket << "trick.var_add(\"vsx.vst.n\")\n"; - socket >> reply; - expected = std::string("0 -1234 0,1,2,3,4"); - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + socket << "trick.var_add(\"vsx.vst.n\")\n"; + socket >> reply; + expected = std::string("0 -1234 0,1,2,3,4"); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - socket << "trick.var_exit()\n"; + socket << "trick.var_exit()\n"; } /*********************************************/ -/* Alt Listener Tests */ +/* Alt Listener Tests */ /*********************************************/ -TEST_F (VariableServerTestAltListener, Strings) { - if (socket_status != 0) { - FAIL(); - } +TEST_F (VariableServerTestAltListener, Strings) { + if (socket_status != 0) { + FAIL(); + } - std::string reply; - socket << "trick.var_send_once(\"vsx.vst.o\")\n"; - socket >> reply; - std::string expected("5\tYou will rejoice to hear that no disaster has accompanied the commencement of an enterprise which you have regarded with such evil forebodings. I arrived here yesterday, and my first task is to assure my dear sister of my welfare and increasing confidence in the success of my undertaking."); + std::string reply; + socket << "trick.var_send_once(\"vsx.vst.o\")\n"; + socket >> reply; + std::string expected("5\tYou will rejoice to hear that no disaster has accompanied the commencement of an enterprise which you have regarded with such evil forebodings. I arrived here yesterday, and my first task is to assure my dear sister of my welfare and increasing confidence in the success of my undertaking."); - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - expected = std::string("5\tI am already far north of London, and as I walk in the streets of Petersburgh, I feel a cold northern breeze play upon my cheeks, which braces my nerves and fills me with delight. Do you understand this feeling?"); - socket << "trick.var_send_once(\"vsx.vst.p\")\n"; + expected = std::string("5\tI am already far north of London, and as I walk in the streets of Petersburgh, I feel a cold northern breeze play upon my cheeks, which braces my nerves and fills me with delight. Do you understand this feeling?"); + socket << "trick.var_send_once(\"vsx.vst.p\")\n"; - socket >> reply; + socket >> reply; - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); } -TEST_F (VariableServerTestAltListener, AddRemove) { - if (socket_status != 0) { - FAIL(); - } +TEST_F (VariableServerTestAltListener, AddRemove) { + if (socket_status != 0) { + FAIL(); + } - std::string reply; - std::string expected; + std::string reply; + std::string expected; - socket << "trick.var_add(\"vsx.vst.c\")\n"; - socket >> reply; - expected = std::string("0 -1234"); + socket << "trick.var_add(\"vsx.vst.c\")\n"; + socket >> reply; + expected = std::string("0 -1234"); - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - socket >> reply; + socket >> reply; - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - socket << "trick.var_add(\"vsx.vst.m\")\n"; - socket >> reply; - expected = std::string("0 -1234 1"); - - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + socket << "trick.var_add(\"vsx.vst.m\")\n"; + socket >> reply; + expected = std::string("0 -1234 1"); + + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - socket << "trick.var_remove(\"vsx.vst.m\")\n"; - socket >> reply; - expected = std::string("0 -1234"); - - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + socket << "trick.var_remove(\"vsx.vst.m\")\n"; + socket >> reply; + expected = std::string("0 -1234"); + + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - socket << "trick.var_add(\"vsx.vst.n\")\n"; - socket >> reply; - expected = std::string("0 -1234 0,1,2,3,4"); - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + socket << "trick.var_add(\"vsx.vst.n\")\n"; + socket >> reply; + expected = std::string("0 -1234 0,1,2,3,4"); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); } -TEST_F (VariableServerTestAltListener, RestartAndSet) { - if (socket_status != 0) { - FAIL(); - } +TEST_F (VariableServerTestAltListener, RestartAndSet) { + if (socket_status != 0) { + FAIL(); + } - std::string reply; - std::string expected; + std::string reply; + std::string expected; - socket << "trick.var_add(\"vsx.vst.c\")\n"; - socket >> reply; - expected = std::string("0\t-1234\n"); + socket << "trick.var_add(\"vsx.vst.c\")\n"; + socket >> reply; + expected = std::string("0\t-1234\n"); - EXPECT_EQ(reply, expected); + EXPECT_EQ(reply, expected); - dump_checkpoint(socket, "reload_file.ckpnt"); + dump_checkpoint(socket, "reload_file.ckpnt"); - socket << "trick.var_add(\"vsx.vst.e\",\"m\")\n"; - socket >> reply; - expected = std::string("0\t-1234\t-123456 {m}\n"); + socket << "trick.var_add(\"vsx.vst.e\",\"m\")\n"; + socket >> reply; + expected = std::string("0\t-1234\t-123456 {m}\n"); - socket << "trick.var_set(\"vsx.vst.c\", 5)\n"; - socket >> reply; - expected = std::string("0\t5\t-123456 {m}\n"); + socket << "trick.var_set(\"vsx.vst.c\", 5)\n"; + socket >> reply; + expected = std::string("0\t5\t-123456 {m}\n"); - EXPECT_EQ(reply, expected); + EXPECT_EQ(reply, expected); - load_checkpoint(socket, "RUN_test/reload_file.ckpnt"); + load_checkpoint(socket, "RUN_test/reload_file.ckpnt"); - socket >> reply; - expected = std::string("0\t-1234\t-123456 {m}\n"); + socket >> reply; + expected = std::string("0\t-1234\t-123456 {m}\n"); - EXPECT_EQ(reply, expected); + EXPECT_EQ(reply, expected); } /*********************************************/ -/* Normal case tests */ +/* Normal case tests */ /*********************************************/ -TEST_F (VariableServerTest, Strings) { - if (socket_status != 0) { - FAIL(); - } +TEST_F (VariableServerTest, Strings) { + if (socket_status != 0) { + FAIL(); + } - std::string reply; - socket << "trick.var_send_once(\"vsx.vst.o\")\n"; - socket >> reply; - std::string expected("5\tYou will rejoice to hear that no disaster has accompanied the commencement of an enterprise which you have regarded with such evil forebodings. I arrived here yesterday, and my first task is to assure my dear sister of my welfare and increasing confidence in the success of my undertaking."); + std::string reply; + socket << "trick.var_send_once(\"vsx.vst.o\")\n"; + socket >> reply; + std::string expected("5\tYou will rejoice to hear that no disaster has accompanied the commencement of an enterprise which you have regarded with such evil forebodings. I arrived here yesterday, and my first task is to assure my dear sister of my welfare and increasing confidence in the success of my undertaking."); - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - expected = std::string("5\tI am already far north of London, and as I walk in the streets of Petersburgh, I feel a cold northern breeze play upon my cheeks, which braces my nerves and fills me with delight. Do you understand this feeling?"); - socket << "trick.var_send_once(\"vsx.vst.p\")\n"; + expected = std::string("5\tI am already far north of London, and as I walk in the streets of Petersburgh, I feel a cold northern breeze play upon my cheeks, which braces my nerves and fills me with delight. Do you understand this feeling?"); + socket << "trick.var_send_once(\"vsx.vst.p\")\n"; - socket >> reply; + socket >> reply; - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - // TODO: Does wchar actually work? - // expected = std::string("5\tThis breeze, which has travelled from the regions towards which I am advancing, gives me a foretaste of those icy climes. Inspirited by this wind of promise, my daydreams become more fervent and vivid."); - // socket << "trick.var_send_once(\"vsx.vst.q\")\n"; + // TODO: Does wchar actually work? + // expected = std::string("5\tThis breeze, which has travelled from the regions towards which I am advancing, gives me a foretaste of those icy climes. Inspirited by this wind of promise, my daydreams become more fervent and vivid."); + // socket << "trick.var_send_once(\"vsx.vst.q\")\n"; - // socket >> reply; + // socket >> reply; - // std::cout << "\tExpected: " << expected << "\n\tActual: " << reply << std::endl; + // std::cout << "\tExpected: " << expected << "\n\tActual: " << reply << std::endl; - // EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + // EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); } -TEST_F (VariableServerTest, NoExtraTab) { - if (socket_status != 0) { - FAIL(); - } +TEST_F (VariableServerTest, NoExtraTab) { + if (socket_status != 0) { + FAIL(); + } - std::string reply; - std::string expected; + std::string reply; + std::string expected; - socket << "trick.var_add(\"vsx.vst.c\")\n"; - socket >> reply; - expected = std::string("0\t-1234\n"); + socket << "trick.var_add(\"vsx.vst.c\")\n"; + socket >> reply; + expected = std::string("0\t-1234\n"); - EXPECT_STREQ(reply.c_str(), expected.c_str()); + EXPECT_STREQ(reply.c_str(), expected.c_str()); - socket >> reply; + socket >> reply; - EXPECT_STREQ(reply.c_str(), expected.c_str()); + EXPECT_STREQ(reply.c_str(), expected.c_str()); - socket << "trick.var_add(\"vsx.vst.m\")\n"; - socket >> reply; - expected = std::string("0\t-1234\t1\n"); - - EXPECT_STREQ(reply.c_str(), expected.c_str()); + socket << "trick.var_add(\"vsx.vst.m\")\n"; + socket >> reply; + expected = std::string("0\t-1234\t1\n"); + + EXPECT_STREQ(reply.c_str(), expected.c_str()); - socket << "trick.var_remove(\"vsx.vst.m\")\n"; - socket >> reply; - expected = std::string("0\t-1234\n"); + socket << "trick.var_remove(\"vsx.vst.m\")\n"; + socket >> reply; + expected = std::string("0\t-1234\n"); - socket << "trick.var_add(\"vsx.vst.n\")\n"; - socket >> reply; - expected = std::string("0\t-1234\t0,1,2,3,4\n"); - - EXPECT_STREQ(reply.c_str(), expected.c_str()); + socket << "trick.var_add(\"vsx.vst.n\")\n"; + socket >> reply; + expected = std::string("0\t-1234\t0,1,2,3,4\n"); + + EXPECT_STREQ(reply.c_str(), expected.c_str()); } -TEST_F (VariableServerTest, AddRemove) { - if (socket_status != 0) { - FAIL(); - } +TEST_F (VariableServerTest, AddRemove) { + if (socket_status != 0) { + FAIL(); + } - std::string reply; - std::string expected; + std::string reply; + std::string expected; - socket << "trick.var_add(\"vsx.vst.c\")\n"; - socket >> reply; - expected = std::string("0 -1234"); + socket << "trick.var_add(\"vsx.vst.c\")\n"; + socket >> reply; + expected = std::string("0 -1234"); - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - socket >> reply; + socket >> reply; - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - socket << "trick.var_add(\"vsx.vst.m\")\n"; - socket >> reply; - expected = std::string("0 -1234 1"); - - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + socket << "trick.var_add(\"vsx.vst.m\")\n"; + socket >> reply; + expected = std::string("0 -1234 1"); + + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - socket << "trick.var_remove(\"vsx.vst.m\")\n"; - socket >> reply; - expected = std::string("0 -1234"); - - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + socket << "trick.var_remove(\"vsx.vst.m\")\n"; + socket >> reply; + expected = std::string("0 -1234"); + + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - socket << "trick.var_add(\"vsx.vst.n\")\n"; - socket >> reply; - expected = std::string("0 -1234 0,1,2,3,4"); - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + socket << "trick.var_add(\"vsx.vst.n\")\n"; + socket >> reply; + expected = std::string("0 -1234 0,1,2,3,4"); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); } -TEST_F (VariableServerTest, BadRefResponse) { - if (socket_status != 0) { - FAIL(); - } +TEST_F (VariableServerTest, BadRefResponse) { + if (socket_status != 0) { + FAIL(); + } - std::string reply; - std::string expected; + std::string reply; + std::string expected; - std::cerr << "The purpose of this test is to cause an error. Error messages are expected." << std::endl; + std::cerr << "The purpose of this test is to cause an error. Error messages are expected." << std::endl; - socket << "trick.var_send_once(\"vsx.vst.no_such_variable\")\n"; - socket >> reply; - expected = std::string("5 BAD_REF"); + socket << "trick.var_send_once(\"vsx.vst.no_such_variable\")\n"; + socket >> reply; + expected = std::string("5 BAD_REF"); - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); } -TEST_F (VariableServerTest, Units) { - if (socket_status != 0) { - FAIL(); - } +TEST_F (VariableServerTest, Units) { + if (socket_status != 0) { + FAIL(); + } - std::string reply; - std::string expected; + std::string reply; + std::string expected; - std::cerr << "The purpose of this test is to cause an error. Error messages are expected." << std::endl; - socket << "trick.var_add(\"vsx.vst.c\")\ntrick.var_units(\"vsx.vst.c\",\"g\")\n"; - socket >> reply; - expected = std::string("0 -1234"); + std::cerr << "The purpose of this test is to cause an error. Error messages are expected." << std::endl; + socket << "trick.var_add(\"vsx.vst.c\")\ntrick.var_units(\"vsx.vst.c\",\"g\")\n"; + socket >> reply; + expected = std::string("0 -1234"); - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - socket << "trick.var_add(\"vsx.vst.e\",\"m\")\n"; - socket >> reply; - expected = std::string("0 -1234 -123456 {m}"); + socket << "trick.var_add(\"vsx.vst.e\",\"m\")\n"; + socket >> reply; + expected = std::string("0 -1234 -123456 {m}"); - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - socket << "trick.var_units(\"vsx.vst.e\",\"ft\")\n"; - socket >> reply; - expected = std::string("0 -1234 -405039 {ft}"); + socket << "trick.var_units(\"vsx.vst.e\",\"ft\")\n"; + socket >> reply; + expected = std::string("0 -1234 -405039 {ft}"); - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); } -TEST_F (VariableServerTest, dump_info) { - if (socket_status != 0) { - FAIL(); - } - socket << "trick.var_add(\"vsx.vst.c\")\n"; +TEST_F (VariableServerTest, dump_info) { + if (socket_status != 0) { + FAIL(); + } + socket << "trick.var_add(\"vsx.vst.c\")\n"; - std::string command = "trick.var_server_list_connections()\n"; - socket << command; - sleep(1); + std::string command = "trick.var_server_list_connections()\n"; + socket << command; + sleep(1); } -TEST_F (VariableServerTest, SendOnce) { - if (socket_status != 0) { - FAIL(); - } +TEST_F (VariableServerTest, SendOnce) { + if (socket_status != 0) { + FAIL(); + } - std::string reply; - std::string expected; + std::string reply; + std::string expected; - socket << "trick.var_send_once(\"vsx.vst.e\")\n"; - socket >> reply; - expected = std::string("5 -123456"); + socket << "trick.var_send_once(\"vsx.vst.e\")\n"; + socket >> reply; + expected = std::string("5 -123456"); - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - // Check that nothing is sent cyclically - EXPECT_EQ(socket.check_for_message_availible(), false); + // Check that nothing is sent cyclically + EXPECT_EQ(socket.check_for_message_availible(), false); - socket << "trick.var_send_once(\"vsx.vst.n[0], vsx.vst.n[1], vsx.vst.n[2],\", 3)\n"; - socket >> reply; - expected = std::string("5 0 1 2"); + socket << "trick.var_send_once(\"vsx.vst.n[0], vsx.vst.n[1], vsx.vst.n[2],\", 3)\n"; + socket >> reply; + expected = std::string("5 0 1 2"); - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - std::cerr << "The purpose of this test is to cause an error. Error messages are expected." << std::endl; - socket << "trick.var_send_once(\"vsx.vst.n[0], vsx.vst.n[1], vsx.vst.n[2],\", 4)\n"; + std::cerr << "The purpose of this test is to cause an error. Error messages are expected." << std::endl; + socket << "trick.var_send_once(\"vsx.vst.n[0], vsx.vst.n[1], vsx.vst.n[2],\", 4)\n"; - // Wrong number of variables, should not send a response but should see an error message from the Trick side - EXPECT_EQ(socket.check_for_message_availible(), false); + // Wrong number of variables, should not send a response but should see an error message from the Trick side + EXPECT_EQ(socket.check_for_message_availible(), false); } -TEST_F (VariableServerTest, Exists) { - if (socket_status != 0) { - FAIL(); - } +TEST_F (VariableServerTest, Exists) { + if (socket_status != 0) { + FAIL(); + } - std::string reply; - std::string expected; + std::string reply; + std::string expected; - socket << "trick.var_exists(\"vsx.vst.e\")\n"; - socket >> reply; - expected = std::string("1 1"); + socket << "trick.var_exists(\"vsx.vst.e\")\n"; + socket >> reply; + expected = std::string("1 1"); - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - socket << "trick.var_exists(\"vsx.vst.z\")\n"; - socket >> reply; - expected = std::string("1 0"); + socket << "trick.var_exists(\"vsx.vst.z\")\n"; + socket >> reply; + expected = std::string("1 0"); - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0); - socket << "trick.var_binary()\n"; + socket << "trick.var_binary()\n"; - std::vector actual_bytes; - std::vector expected_bytes; - socket << "trick.var_exists(\"vsx.vst.e\")\n"; - actual_bytes = socket.receive_bytes(); - expected_bytes = {0x01, 0x00, 0x00, 0x00, 0x01}; + std::vector actual_bytes; + std::vector expected_bytes; + socket << "trick.var_exists(\"vsx.vst.e\")\n"; + actual_bytes = socket.receive_bytes(); + expected_bytes = {0x01, 0x00, 0x00, 0x00, 0x01}; - EXPECT_EQ(expected_bytes, actual_bytes); + EXPECT_EQ(expected_bytes, actual_bytes); - socket << "trick.var_exists(\"vsx.vst.z\")\n"; - actual_bytes = socket.receive_bytes(); - expected_bytes = {0x01, 0x00, 0x00, 0x00, 0x00}; + socket << "trick.var_exists(\"vsx.vst.z\")\n"; + actual_bytes = socket.receive_bytes(); + expected_bytes = {0x01, 0x00, 0x00, 0x00, 0x00}; - EXPECT_EQ(expected_bytes, actual_bytes); + EXPECT_EQ(expected_bytes, actual_bytes); } -TEST_F (VariableServerTest, ListSize) { - if (socket_status != 0) { - FAIL(); - } +TEST_F (VariableServerTest, ListSize) { + if (socket_status != 0) { + FAIL(); + } - std::string reply; - std::string expected; + std::string reply; + std::string expected; - socket << "trick.var_add(\"vsx.vst.a\")\ntrick.var_add(\"vsx.vst.b\")\ntrick.var_add(\"vsx.vst.c\")\ntrick.var_add(\"vsx.vst.d\")\ntrick.var_pause()\n"; - socket << "trick.var_send_list_size()\n"; + socket << "trick.var_add(\"vsx.vst.a\")\ntrick.var_add(\"vsx.vst.b\")\ntrick.var_add(\"vsx.vst.c\")\ntrick.var_add(\"vsx.vst.d\")\ntrick.var_pause()\n"; + socket << "trick.var_send_list_size()\n"; - socket >> reply; - expected = "3 4"; + socket >> reply; + expected = "3 4"; - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0) << "Reply: " << reply << "\tExpected: " << expected; + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0) << "Reply: " << reply << "\tExpected: " << expected; - // Adding a variable to the list more than once is allowed - socket << "trick.var_add(\"vsx.vst.a\")\n"; - socket << "trick.var_send_list_size()\n"; + // Adding a variable to the list more than once is allowed + socket << "trick.var_add(\"vsx.vst.a\")\n"; + socket << "trick.var_send_list_size()\n"; - socket >> reply; - expected = "3 5"; + socket >> reply; + expected = "3 5"; - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0) << "Reply: " << reply << "\tExpected: " << expected; + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply, expected), 0) << "Reply: " << reply << "\tExpected: " << expected; - socket << "trick.var_add(\"vsx.vst.e\")\ntrick.var_binary()\ntrick.var_send_list_size()\n"; + socket << "trick.var_add(\"vsx.vst.e\")\ntrick.var_binary()\ntrick.var_send_list_size()\n"; - std::vector actual_bytes; - std::vector expected_bytes; - actual_bytes = socket.receive_bytes(); - expected_bytes = {0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00}; + std::vector actual_bytes; + std::vector expected_bytes; + actual_bytes = socket.receive_bytes(); + expected_bytes = {0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00}; - EXPECT_EQ(expected_bytes, actual_bytes); + EXPECT_EQ(expected_bytes, actual_bytes); } -TEST_F (VariableServerTest, bitfields) { - if (socket_status != 0) { - FAIL(); - } +TEST_F (VariableServerTest, bitfields) { + if (socket_status != 0) { + FAIL(); + } - socket << "trick.var_send_once(\"vsx.vst.my_bitfield.var1,vsx.vst.my_bitfield.var2,vsx.vst.my_bitfield.var3,vsx.vst.my_bitfield.var4\", 4)\n"; - std::string reply_str; - socket >> reply_str; + socket << "trick.var_send_once(\"vsx.vst.my_bitfield.var1,vsx.vst.my_bitfield.var2,vsx.vst.my_bitfield.var3,vsx.vst.my_bitfield.var4\", 4)\n"; + std::string reply_str; + socket >> reply_str; - EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply_str, "5 3 -128 0 2112"), 0); + EXPECT_EQ(strcmp_IgnoringWhiteSpace(reply_str, "5 3 -128 0 2112"), 0); - socket << "trick.var_binary()\ntrick.var_send_once(\"vsx.vst.my_bitfield.var1,vsx.vst.my_bitfield.var2,vsx.vst.my_bitfield.var3,vsx.vst.my_bitfield.var4\", 4)\n"; + socket << "trick.var_binary()\ntrick.var_send_once(\"vsx.vst.my_bitfield.var1,vsx.vst.my_bitfield.var2,vsx.vst.my_bitfield.var3,vsx.vst.my_bitfield.var4\", 4)\n"; - std::vector reply = socket.receive_bytes(); + std::vector reply = socket.receive_bytes(); - ParsedBinaryMessage message; - try { - message.parse(reply); - } catch (const MalformedMessageException& ex) { - FAIL() << "Parser threw an exception: " << ex.what(); - } + ParsedBinaryMessage message; + try { + message.parse(reply); + } catch (const MalformedMessageException& ex) { + FAIL() << "Parser threw an exception: " << ex.what(); + } - for (int i = 0; i < message.getNumVars(); i++) { - EXPECT_TRUE(message.variables[i].getType() == 12 || message.variables[i].getType() == 13); - } + for (int i = 0; i < message.getNumVars(); i++) { + EXPECT_TRUE(message.variables[i].getType() == 12 || message.variables[i].getType() == 13); + } } -TEST_F (VariableServerTest, transmit_file) { - if (socket_status != 0) { - FAIL(); - } +TEST_F (VariableServerTest, transmit_file) { + if (socket_status != 0) { + FAIL(); + } - socket << "trick.send_file(\"file_to_send.txt\")\n"; + socket << "trick.send_file(\"file_to_send.txt\")\n"; - std::stringstream file_contents; + std::stringstream file_contents; - while (socket.check_for_message_availible()) { - socket >> file_contents; - } + while (socket.check_for_message_availible()) { + socket >> file_contents; + } - std::ifstream actual_file("file_to_send.txt"); - std::string expected_contents; - getline(actual_file, expected_contents); + std::ifstream actual_file("file_to_send.txt"); + std::string expected_contents; + getline(actual_file, expected_contents); - std::string expected_header = "2\t" + std::to_string(expected_contents.size()); + std::string expected_header = "2\t" + std::to_string(expected_contents.size()); - std::string test_line; + std::string test_line; - std::getline(file_contents, test_line); - EXPECT_EQ(test_line, expected_header); + std::getline(file_contents, test_line); + EXPECT_EQ(test_line, expected_header); - std::getline(file_contents, test_line); - EXPECT_EQ(test_line, expected_contents); + std::getline(file_contents, test_line); + EXPECT_EQ(test_line, expected_contents); } -TEST_F (VariableServerTest, SendSieResource) { - if (socket_status != 0) { - FAIL(); - } +TEST_F (VariableServerTest, SendSieResource) { + if (socket_status != 0) { + FAIL(); + } - socket << "trick.send_sie_resource()\n"; + socket << "trick.send_sie_resource()\n"; - std::stringstream received_file; + std::stringstream received_file; - while (socket.check_for_message_availible()) { - socket >> received_file; - } + while (socket.check_for_message_availible()) { + socket >> received_file; + } - std::string first_line; - std::getline(received_file, first_line); + std::string first_line; + std::getline(received_file, first_line); - // We're not gonna bother comparing the contents - // Just check to see that the message type is correct - ASSERT_EQ(first_line.at(0), '2'); + // We're not gonna bother comparing the contents + // Just check to see that the message type is correct + ASSERT_EQ(first_line.at(0), '2'); } -TEST_F (VariableServerTest, SendSieClass) { - if (socket_status != 0) { - FAIL(); - } +TEST_F (VariableServerTest, SendSieClass) { + if (socket_status != 0) { + FAIL(); + } - socket << "trick.send_sie_class()\n"; + socket << "trick.send_sie_class()\n"; - std::stringstream received_file; - std::string file_temp; + std::stringstream received_file; + std::string file_temp; - while (socket.check_for_message_availible()) { - socket >> file_temp; - received_file << file_temp; - } + while (socket.check_for_message_availible()) { + socket >> file_temp; + received_file << file_temp; + } - std::string first_line; - std::getline(received_file, first_line); + std::string first_line; + std::getline(received_file, first_line); - // We're not gonna bother comparing the contents - // Just check to see that the message type is correct - ASSERT_EQ(first_line.at(0), '2'); + // We're not gonna bother comparing the contents + // Just check to see that the message type is correct + ASSERT_EQ(first_line.at(0), '2'); } -TEST_F (VariableServerTest, SendSieEnum) { - if (socket_status != 0) { - FAIL(); - } +TEST_F (VariableServerTest, SendSieEnum) { + if (socket_status != 0) { + FAIL(); + } - socket << "trick.send_sie_enum()\n"; + socket << "trick.send_sie_enum()\n"; - std::stringstream received_file; - std::string file_temp; + std::stringstream received_file; + std::string file_temp; - while (socket.check_for_message_availible()) { - socket >> file_temp; - received_file << file_temp; - } + while (socket.check_for_message_availible()) { + socket >> file_temp; + received_file << file_temp; + } - std::string first_line; - std::getline(received_file, first_line); + std::string first_line; + std::getline(received_file, first_line); - // We're not gonna bother comparing the contents - // Just check to see that the message type is correct - ASSERT_EQ(first_line.at(0), '2'); + // We're not gonna bother comparing the contents + // Just check to see that the message type is correct + ASSERT_EQ(first_line.at(0), '2'); } -TEST_F (VariableServerTest, SendSieClassTopLevelObjects) { - if (socket_status != 0) { - FAIL(); - } +TEST_F (VariableServerTest, SendSieClassTopLevelObjects) { + if (socket_status != 0) { + FAIL(); + } - socket << "trick.send_sie_top_level_objects()\n"; + socket << "trick.send_sie_top_level_objects()\n"; - std::stringstream received_file; - std::string file_temp; + std::stringstream received_file; + std::string file_temp; - while (socket.check_for_message_availible()) { - socket >> file_temp; - received_file << file_temp; - } + while (socket.check_for_message_availible()) { + socket >> file_temp; + received_file << file_temp; + } - std::string first_line; - std::getline(received_file, first_line); + std::string first_line; + std::getline(received_file, first_line); - // We're not gonna bother comparing the contents - // Just check to see that the message type is correct - ASSERT_EQ(first_line.at(0), '2'); + // We're not gonna bother comparing the contents + // Just check to see that the message type is correct + ASSERT_EQ(first_line.at(0), '2'); } -TEST_F (VariableServerTest, RestartAndSet) { - if (socket_status != 0) { - FAIL(); - } +TEST_F (VariableServerTest, RestartAndSet) { + if (socket_status != 0) { + FAIL(); + } - std::string reply; - std::string expected; + std::string reply; + std::string expected; - socket << "trick.var_add(\"vsx.vst.c\")\n"; - socket >> reply; - expected = std::string("0\t-1234\n"); + socket << "trick.var_add(\"vsx.vst.c\")\n"; + socket >> reply; + expected = std::string("0\t-1234\n"); - EXPECT_EQ(reply, expected); + EXPECT_EQ(reply, expected); - dump_checkpoint(socket, "reload_file.ckpnt"); + dump_checkpoint(socket, "reload_file.ckpnt"); - socket << "trick.var_add(\"vsx.vst.e\",\"m\")\n"; - socket >> reply; - expected = std::string("0\t-1234\t-123456 {m}\n"); + socket << "trick.var_add(\"vsx.vst.e\",\"m\")\n"; + socket >> reply; + expected = std::string("0\t-1234\t-123456 {m}\n"); - socket << "trick.var_set(\"vsx.vst.c\", 5)\n"; - socket >> reply; - expected = std::string("0\t5\t-123456 {m}\n"); + socket << "trick.var_set(\"vsx.vst.c\", 5)\n"; + socket >> reply; + expected = std::string("0\t5\t-123456 {m}\n"); - EXPECT_EQ(reply, expected); + EXPECT_EQ(reply, expected); - load_checkpoint(socket, "RUN_test/reload_file.ckpnt"); + load_checkpoint(socket, "RUN_test/reload_file.ckpnt"); - socket >> reply; - expected = std::string("0\t-1234\t-123456 {m}\n"); + socket >> reply; + expected = std::string("0\t-1234\t-123456 {m}\n"); - EXPECT_EQ(reply, expected); + EXPECT_EQ(reply, expected); } -TEST_F (VariableServerTest, Cycle) { - if (socket_status != 0) { - FAIL(); - } - - double cycle = 1.0; - int num_cycles = 5; - - // Challenge: no loops allowed - // I've been reading about lamdbas and when you have a hammer........ - - // Test: compare the differences in the returned sim time, make sure the difference - // between them are equal to var_cycle - // In copy mode VS_COPY_SCHEDULED and write mode VS_WRITE_WHEN_COPY, we should see exactly the correct copy rate - // Use a very small tolerance to compensate for floating point error - - auto parse_message_for_sim_time = [](const std::string& message) { - // For this case the message will be - // 0\t