BOOST_FIXTURE_TEST_CASE( write_queue_used_by_other_client, large_fixture )
{
    connection_data con1( 23 );
    connection_data con2( 23 );

    l2cap_input( { 0x16, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01 }, con1 );
    expected_result( { 0x17, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01 } );

    l2cap_input( { 0x16, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01 }, con2 );
    expected_result( { 0x01, 0x16, 0x03, 0x00, 0x09 } );
}
BOOST_FIXTURE_TEST_CASE( prepare_3_writes, test::request_with_reponse< three_apes_server > )
{
    l2cap_input( { 0x16, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01 } );
    expected_result( { 0x17, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01 } );

    l2cap_input( { 0x16, 0x05, 0x00, 0x00, 0x00, 0x00, 0x02 } );
    expected_result( { 0x17, 0x05, 0x00, 0x00, 0x00, 0x00, 0x02 } );

    l2cap_input( { 0x16, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03 } );
    expected_result( { 0x17, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03 } );
}
BOOST_FIXTURE_TEST_CASE( queue_can_be_used_after_beeing_released, test::request_with_reponse< three_apes_server > )
{
    connection_data con1( 23 );
    connection_data con2( 23 );

    l2cap_input( { 0x16, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01 }, con1 );

    l2cap_input( { 0x16, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01 }, con2 );
    expected_result( { 0x01, 0x16, 0x03, 0x00, 0x09 } );

    this->client_disconnected( con1 );

    l2cap_input( { 0x16, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01 }, con2 );
    expected_result( { 0x17, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01 } );
}
示例#4
0
BOOST_FIXTURE_TEST_CASE( should_find_the_device_name_characteristic, request_with_reponse< small_temperature_service > )
{
    l2cap_input( { 0x02, 0x68, 0x00 } );
    expected_result( { 0x03, 0x17, 0x00 } );

    l2cap_input( { 0x08, 0x01, 0x00, 0xff, 0xff, 0x00, 0x2a } );
    BOOST_REQUIRE( response_size > 0 );
    BOOST_CHECK_EQUAL( response[ 0 ], 0x09 );
}
// service is discoverable and contains at least two characteristics
BOOST_FIXTURE_TEST_CASE( service_is_discoverable_by_default, test::request_with_reponse< nupsy_service > )
{
    // Find By Type Value Request, 1, 0xffff, <<primary service>>, <<gap service>>
    l2cap_input( { 0x06, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28, 0x00, 0x18 } );
    expected_result( {
        0x07,
        0x04, 0x00, 0x08, 0x00
    } );
}
示例#6
0
	TEST(UtilDateTime, fixDateTimeString_very_short_string)
	{
		std::string input_string("201007");
		std::string expected_result("");

		std::string s = UTIL::MISC::fixDateTimeString(input_string.c_str());

		ASSERT_STREQ(expected_result.c_str(), s.c_str());
	}
示例#7
0
	TEST(UtilDateTime, fixDateTimeString_missing_t)
	{
		std::string input_string("20150410345612");
		std::string expected_result("20150410T345612");

		std::string s = UTIL::MISC::fixDateTimeString(input_string.c_str());

		ASSERT_STREQ(expected_result.c_str(), s.c_str());
	}
示例#8
0
	TEST(UtilDateTime, fixDateTimeString_valid_string)
	{
		std::string input_string("20131025T123456");
		std::string expected_result(input_string);

		std::string s = UTIL::MISC::fixDateTimeString(input_string.c_str());

		ASSERT_STREQ(expected_result.c_str(), s.c_str());
	}
BOOST_FIXTURE_TEST_CASE( appearance_is_mandatory, test::request_with_reponse< nupsy_service > )
{
    // Read by Type Request, 0x0001, 0xffff, 0x2A01
    l2cap_input( { 0x08, 0x01, 0x00, 0xff, 0xff, 0x01, 0x2A } );
    expected_result( {
        0x09,
        0x04, 0x08, 0x00, 0x00, 0x00
    } );
}
BOOST_FIXTURE_TEST_CASE( configured_appearance_is_used, test::request_with_reponse< location_and_navigation_display_device_server > )
{
    // Read by Type Request, 0x0001, 0xffff, 0x2A01
    l2cap_input( { 0x08, 0x01, 0x00, 0xff, 0xff, 0x01, 0x2A } );
    expected_result( {
        0x09,
        0x04, 0x08, 0x00, 0x42, 0x14
    } );
}
BOOST_FIXTURE_TEST_CASE( device_name_is_mandatory, test::request_with_reponse< nupsy_service > )
{
    // Read by Type Request, 0x0001, 0xffff, 0x2A00
    l2cap_input( { 0x08, 0x01, 0x00, 0xff, 0xff, 0x00, 0x2A } );
    expected_result( {
        0x09,
        0x0e, 0x06, 0x00, // length + handle
        // "Nupsy-Server"
        'N', 'u', 'p', 's', 'y', '-', 'S', 'e', 'r', 'v', 'e', 'r'
    } );
}
BOOST_FIXTURE_TEST_CASE( default_name, test::request_with_reponse< no_name_service > )
{
    // Read by Type Request, 0x0001, 0xffff, 0x2A00
    l2cap_input( { 0x08, 0x01, 0x00, 0xff, 0xff, 0x00, 0x2A } );
    expected_result( {
        0x09,
        0x10, 0x06, 0x00, // length + handle
        // "Bluetoe-Server"
        'B', 'l', 'u', 'e', 't', 'o', 'e', '-', 'S', 'e', 'r', 'v', 'e', 'r'
    } );
}
   void QuatOpsTest::testQuatInvert()
   {
      // test out mult( result, quat, quat )
      const float eps = 0.0001f;
      gmtl::Quat<float> q( 0.2f, 0.33f, 0.44f, 0.101f ), expected_result( -0.567053f, -0.935637f, -1.24752f, 0.286362f );
      gmtl::Quat<float> q2( q );
      gmtl::Quat<float> q3( gmtl::invert( q2 ) );
      CPPUNIT_ASSERT( gmtl::isEqual( expected_result, q3, eps ) );
      CPPUNIT_ASSERT( gmtl::isEqual( expected_result, q2, eps ) );

      gmtl::Quat<float> q4( gmtl::makeInvert( q ) );
      CPPUNIT_ASSERT( gmtl::isEqual( expected_result, q4, eps ) );
   }
示例#14
0
   void QuatGenTest::testQuatMakeInvert()
   {
      // test out mult( result, quat, quat )
      const float eps = 0.0001f;
      gmtl::Quat<float> q( 0.2f, 0.33f, 0.44f, 0.101f ), expected_result( -0.567053f, -0.935637f, -1.24752f, 0.286362f );
      gmtl::Quat<float> q4( gmtl::makeInvert( q ) );
      CPPUNIT_ASSERT( gmtl::isEqual( expected_result, q4, eps ) );

      // make sure set works the same
      /// @todo no impl
      // gmtl::Quat<float> q5;
      //gmtl::setInvert( q5, q );
      //CPPUNIT_ASSERT( gmtl::isEqual( expected_result, q5, eps ) );
   }
示例#15
0
	void m3math_test_object_t::test<7>()
	{
		LLMatrix3 llmat_obj1;
		LLVector3d llvec3d1;		
		LLVector3d llvec3d2(0, 3, 4);

		LLVector3 llvec1(1, 3, 5);
		LLVector3 llvec2(3, 2, 1);
		LLVector3 llvec3(4, 6, 0);
		
		llmat_obj1.setRows(llvec1, llvec2, llvec3);
		llvec3d1 = llvec3d2 * llmat_obj1;

		LLVector3d expected_result(25, 30, 3);
		
		ensure("LLMatrix3::operator*(const LLVector3 &a, const LLMatrix3 &b) failed", llvec3d1 == expected_result);
	}
示例#16
0
	void m3math_test_object_t::test<6>()
	{
				
		LLMatrix3 llmat_obj1;
		
		LLVector3 llvec(1, 3, 5);
		LLVector3 res_vec(0, 0, 0);
		LLVector3 llvec1(1, 3, 5);
		LLVector3 llvec2(3, 6, 1);
		LLVector3 llvec3(4, 6, 9);
		
		llmat_obj1.setRows(llvec1, llvec2, llvec3);
		res_vec = llvec * llmat_obj1;

		LLVector3 expected_result(30, 51, 53);

		ensure("LLMatrix3::operator*(const LLVector3 &a, const LLMatrix3 &b) failed", res_vec == expected_result);
	}
示例#17
0
	TEST(UtilDateTime, dateTimeToDisplay_simple_test)
	{
		// only do this for USA locales. Constructing locale here and using it to generate
		// expected string is what happens in code being tested so not a good unit test
		std::locale my_locale("");
		if (my_locale.name().find("United States") != std::string::npos)
		{
			std::string input_string("20110708T201530");
			std::string expected_result("07/08/11");

			std::string s = UTIL::MISC::dateTimeToDisplay(input_string.c_str());

			ASSERT_STREQ(expected_result.c_str(), s.c_str());
		}
		else
		{
			std::cerr << "Warning - locale not USA - dateTimeToDisplay_simple_test not executing" << std::endl;
		}
	}
int check_result(struct gameState myState, struct gameState copyState, int choice1, int choice2, int choice3, int myKingdomCards[10], int result, int handPos)
{
	int er_return = expected_result(&copyState, choice1, choice2, choice3, handPos, myKingdomCards);

	if( result == -1 && er_return == 0 )
	{
		printf("FAILURE: Test failed on valid inputs.\n");
		return 1;
	}
	else if(result == 0 && er_return == -1)
	{
		printf("FAILURE: Function did not fail on invalid input.\n");
		return 1;
	}
	else if(result == 0 && er_return == 0)
	{
		return compare_results(myState, copyState, choice1);
	}
	return 0;
}
示例#19
0
文件: logging_test.c 项目: ekr/daala
int main(int argc, char **argv) {
  int i;
  ogg_int16_t int16_buffer[BUFFER_WIDTH * BUFFER_HEIGHT];
  float float_buffer[BUFFER_WIDTH * BUFFER_HEIGHT];
  ogg_uint32_t uint32_buffer[BUFFER_WIDTH * BUFFER_HEIGHT];
  (void)argc;
  (void)argv;

  /* Test the basic functionality. */
  setenv("OD_LOG_MODULES", "generic:3", 1);
  od_log_init(od_logging_test_emit);

  /* This should log. */
  reset_result();
  OD_LOG((OD_LOG_GENERIC, OD_LOG_ERR, "Blah blah %s:%d", "XXX", 9));
  expected_result("Blah blah XXX:9");

  /* This should not log (level too low) */
  reset_result();
  OD_LOG((OD_LOG_GENERIC, OD_LOG_DEBUG, "Blah blah %s:%d", "XXX", 9));
  expected_nothing();

  /* This should not log (facility not set) */
  reset_result();
  OD_LOG((OD_LOG_ENTROPY_CODER, OD_LOG_ERR, "Blah blah %s:%d", "XXX", 9));
  expected_nothing();

  /* Test multiple modules */
  setenv("OD_LOG_MODULES", "generic:3,entropy-coder:5", 1);
  od_log_init(od_logging_test_emit);
  reset_result();
  OD_LOG((OD_LOG_GENERIC, OD_LOG_DEBUG, "Blah blah %s:%d", "XXX", 9));
  expected_nothing();

  reset_result();
  OD_LOG((OD_LOG_ENTROPY_CODER, OD_LOG_DEBUG, "Blah blah %s:%d", "XXX", 9));
  expected_something();

  /* Test multiple modules in the other order*/
  setenv("OD_LOG_MODULES", "entropy-coder:5,generic:3", 1);
  od_log_init(od_logging_test_emit);
  reset_result();
  OD_LOG((OD_LOG_GENERIC, OD_LOG_DEBUG, "Blah blah %s:%d", "XXX", 9));
  expected_nothing();

  reset_result();
  OD_LOG((OD_LOG_ENTROPY_CODER, OD_LOG_DEBUG, "Blah blah %s:%d", "XXX", 9));
  expected_something();

  /* Test bogus module string */
  setenv("OD_LOG_MODULES", "generic:XXX,blahblah:9,entropy-coder:5", 1);
  od_log_init(od_logging_test_emit);
  reset_result();
  OD_LOG((OD_LOG_GENERIC, OD_LOG_ERR, "Blah blah %s:%d", "XXX", 9));
  expected_nothing();

  reset_result();
  OD_LOG((OD_LOG_ENTROPY_CODER, OD_LOG_DEBUG, "Blah blah %s:%d", "XXX", 9));
  expected_something();

  /* Test a ridiculous fmt string */
  memset(bogus_fmt_string, 'X', sizeof(bogus_fmt_string));
  bogus_fmt_string[sizeof(bogus_fmt_string) - 2] = 'Y';
  bogus_fmt_string[sizeof(bogus_fmt_string) - 1] = '\0';
  OD_LOG((OD_LOG_ENTROPY_CODER, OD_LOG_DEBUG, bogus_fmt_string, "XXX", 9));


  /* Test matrices */
  for (i=0; i<(BUFFER_WIDTH * BUFFER_HEIGHT); ++i) {
    int16_buffer[i] = 1000 + i;
  }
  reset_result();
  od_log_matrix_int16(OD_LOG_ENTROPY_CODER, OD_LOG_DEBUG, "PREFIX:",
                    int16_buffer, BUFFER_WIDTH, BUFFER_HEIGHT);
  expected_result(expected_matrix_int16);

  for (i=0; i<(BUFFER_WIDTH * BUFFER_HEIGHT); ++i) {
    float_buffer[i] = 1 + (float)i / 1000;
  }
  reset_result();
  od_log_matrix_float(OD_LOG_ENTROPY_CODER, OD_LOG_DEBUG, "PREFIX:",
                    float_buffer, BUFFER_WIDTH, BUFFER_HEIGHT);
  expected_result(expected_matrix_float);

  for (i=0; i<(BUFFER_WIDTH * BUFFER_HEIGHT); ++i) {
    uint32_buffer[i] = 1000000 + i;
  }
  reset_result();
  od_log_matrix_uint32(OD_LOG_ENTROPY_CODER, OD_LOG_DEBUG, "PREFIX:",
                       uint32_buffer, BUFFER_WIDTH, BUFFER_HEIGHT);
  expected_result(expected_matrix_uint32);

  if (failed)
    exit(1);

  exit(0);
}