Ejemplo n.º 1
0
int main(int argc, char** argv) 
{
  // default arguments
  autopilot_parms.bearing_noise=fixed(0);
  autopilot_parms.target_noise=fixed(0.1);
  autopilot_parms.turn_speed=fixed(5.0);
  output_skip = 5;

  if (!parse_args(argc,argv)) {
    return 0;
  }

#define NUM_FLIGHT 2

  plan_tests(NUM_FLIGHT*2);

  for (int i=0; i<NUM_FLIGHT; i++) {
    unsigned k = rand()%NUM_WIND;
    ok (test_aat(2,k), test_name("target ",2,k),0);
  }
  for (int i=0; i<NUM_FLIGHT; i++) {
    unsigned k = rand()%NUM_WIND;
    ok (test_aat(0,k), test_name("target ",0,k),0);
  }
  return exit_status();
}
Ejemplo n.º 2
0
static bool
test_speed_factor(int test_num, int n_wind)
{
  // flying at opt speed should be minimum time flight!

  double te0, te1, te2;

  TestFlightResult result = test_flight(test_num, n_wind, 1.0);
  te0 = result.time_elapsed;

  result = test_flight(test_num, n_wind, 0.7);
  te1 = result.time_elapsed;
  // time of this should be higher than nominal
  ok(te0 < te1, test_name("vopt slow or", test_num, n_wind), 0);

  result = test_flight(test_num, n_wind, 1.5);
  te2 = result.time_elapsed;
  // time of this should be higher than nominal
  ok(te0 < te2, test_name("vopt fast or", test_num, n_wind), 0);

  bool retval = (te0 < te1) && (te0 < te2);
  if (verbose || !retval) {
    printf("# sf 0.8 time_elapsed_rat %g\n", te1 / te0);
    printf("# sf 1.2 time_elapsed_rat %g\n", te2 / te0);
  }
  return retval;
}
Ejemplo n.º 3
0
int
main(int argc, char **argv)
{
    hx509_context context;
    int ret = 0;

    ret = hx509_context_init(&context);
    if (ret)
	errx(1, "hx509_context_init failed with %d", ret);

    ret += test_name(context, "CN=foo,C=SE");
    ret += test_name(context, "CN=foo,CN=kaka,CN=FOO,DC=ad1,C=SE");
    ret += test_name(context, "1.2.3.4=foo,C=SE");
    ret += test_name_fail(context, "=");
    ret += test_name_fail(context, "CN=foo,=foo");
    ret += test_name_fail(context, "CN=foo,really-unknown-type=foo");

    ret += test_expand(context, "UID=${uid},C=SE", "UID=lha,C=SE");
    ret += test_expand(context, "UID=foo${uid},C=SE", "UID=foolha,C=SE");
    ret += test_expand(context, "UID=${uid}bar,C=SE", "UID=lhabar,C=SE");
    ret += test_expand(context, "UID=f${uid}b,C=SE", "UID=flhab,C=SE");
    ret += test_expand(context, "UID=${uid}${uid},C=SE", "UID=lhalha,C=SE");
    ret += test_expand(context, "UID=${uid}{uid},C=SE", "UID=lha{uid},C=SE");

    ret += test_compare(context);

    hx509_context_free(&context);

    return ret;
}
Ejemplo n.º 4
0
static int test_basic_totp(void) {
  struct r2fa_totp_cfg cfg;
  char code[] = "qwerty", key[] = "12345678901234567890";
  int ret;

  test_name("totp: test_basic_totp");

  ret = r2fa_totp_init(&cfg);
  assert(ret == R2FA_OATH_SUCCESS);
  assert(cfg.key == NULL);
  assert(cfg.key_len == 0);
  assert(cfg.timestamp != 0);
  assert(cfg.period == 30);
  assert(cfg.initial_time == 0);
  assert(cfg.output_len == 6);
  assert(cfg.output_base == NULL);
  assert(cfg.output_base_len == 0);
  assert(cfg.hash_function == R2FA_OATH_SHA_1);

  cfg.key = key;
  cfg.key_len = sizeof(key);

  ret = r2fa_totp_generate(&cfg, code);
  assert(ret == R2FA_OATH_SUCCESS);
  assert(strlen(code) == 6);
  assert(!r2fa_totp_is_valid(NULL, "755224"));
  assert(!r2fa_totp_is_valid(&cfg, "4755224"));
  assert(!r2fa_totp_is_valid(&cfg, "!@#$%^"));
  assert(!r2fa_totp_is_valid(&cfg, ""));
  assert(!r2fa_totp_is_valid(&cfg, NULL));

  return 1;
}
Ejemplo n.º 5
0
void EquivalenceTest::generate(DexClass* cls) {
  setup(cls);
  auto ret = DexType::make_type("I");
  auto args = DexTypeList::make_type_list({});
  auto proto = DexProto::make_proto(ret, args); // I()
  DexMethod* before = static_cast<DexMethod*>(DexMethod::make_method(
      cls->get_type(), DexString::make_string("before_" + test_name()), proto));
  before->make_concrete(ACC_PUBLIC | ACC_STATIC, false);
  before->set_code(std::make_unique<IRCode>(before, 0));
  build_method(before);
  cls->add_method(before);
  auto after = DexMethod::make_method_from(
      before, cls->get_type(), DexString::make_string("after_" + test_name()));
  cls->add_method(after);
  transform_method(after);
}
Ejemplo n.º 6
0
static int test_advanced_totp(void) {
  struct r2fa_totp_cfg cfg;
  char code[9], key[] = "12345678901234567890123456789012";
  int ret;

  test_name("totp: test_advanced_totp");
  ret = r2fa_totp_init(&cfg);
  assert(ret == R2FA_OATH_SUCCESS);

  cfg.key = key;
  cfg.key_len = sizeof(key);
  cfg.timestamp = 1111111109;
  cfg.output_len = 8;
  cfg.hash_function = R2FA_OATH_SHA_256;

  ret = r2fa_totp_generate(&cfg, code);
  assert(ret == R2FA_OATH_SUCCESS);
  assert(strlen(code) == 8);
  assert(strncmp(code, "68084774", 9) == 0);

  assert(r2fa_totp_is_valid(&cfg, "68084774"));
  assert(!r2fa_totp_is_valid(NULL, "68084774"));
  assert(!r2fa_totp_is_valid(&cfg, "68084775"));
  assert(!r2fa_totp_is_valid(&cfg, "46808477"));
  assert(!r2fa_totp_is_valid(&cfg, "!@#$%^&*"));
  assert(!r2fa_totp_is_valid(&cfg, ""));
  assert(!r2fa_totp_is_valid(&cfg, NULL));

  return 1;
}
Ejemplo n.º 7
0
std::pair<HRESULT, std::string> UnicodeStringStructToString(const ExtRemoteTyped &unicode_string) {
    std::string output_string = "";

    try {
        ExtRemoteTyped loc_unicode_string = unicode_string;
        ExtRemoteTyped buffer = *loc_unicode_string.Field("Buffer");
        uint16_t len = loc_unicode_string.Field("Length").GetUshort();
        uint16_t maxlen = loc_unicode_string.Field("MaximumLength").GetUshort();

        if ( len == 0 && maxlen == 1 ) {
            return std::make_pair(S_OK, output_string);
        }

        if ( maxlen >= sizeof(wchar_t) && (maxlen % sizeof(wchar_t) == 0) ) {
            uint16_t max_len_wide = maxlen / sizeof(wchar_t) + 1;

            std::unique_ptr<wchar_t[]> test_name(new wchar_t[max_len_wide]);
            std::memset(test_name.get(), 0, max_len_wide * sizeof(wchar_t));

            uint32_t read = buffer.ReadBuffer(test_name.get(), maxlen, true);

            if ( read == maxlen )
                output_string = wstring_to_string(test_name.get());

            return std::make_pair(S_OK, output_string);
        }
    } catch ( const ExtRemoteException &Ex ) {
        std::stringstream locerr;

        locerr << wa::showminus << __FUNCTION__ << ": " << Ex.GetMessage() << wa::endlerr;
        return std::make_pair(Ex.GetStatus(), output_string);
    }

    return std::make_pair(E_INVALIDARG, output_string);
}
Ejemplo n.º 8
0
static int test_generate_null_ptr(void) {
  struct r2fa_totp_cfg cfg;
  char code[] = "qwerty", key[] = "12345678901234567890";
  int ret;

  test_name("totp: test_generate_null_ptr");
  r2fa_totp_init(&cfg);

  ret = r2fa_totp_generate(NULL, code);
  assert(ret == R2FA_OATH_CFG_NULL_PTR);
  assert(strcmp(code, "qwerty") == 0);

  ret = r2fa_totp_generate(&cfg, code);
  assert(ret == R2FA_OATH_KEY_NULL_PTR);

  cfg.key = key;

  ret = r2fa_totp_generate(&cfg, code);
  assert(ret == R2FA_OATH_INVALID_KEY_LEN);

  cfg.key_len = sizeof(key);

  ret = r2fa_totp_generate(&cfg, NULL);
  assert(ret == R2FA_OATH_CODE_NULL_PTR);

  ret = r2fa_totp_generate(&cfg, code);
  assert(ret == R2FA_OATH_SUCCESS);

  return 1;
}
Ejemplo n.º 9
0
BOOL CALLBACK WDbgArkColorHack::EnumWindowsProc(HWND hwnd, LPARAM lParam) {
    bool*            found = reinterpret_cast<bool*>(lParam);
    unsigned __int32 pid   = 0;

    GetWindowThreadProcessId(hwnd, reinterpret_cast<LPDWORD>(&pid));

    if ( pid == GetCurrentProcessId() ) {
        HWND top_window = GetTopWindow(hwnd);

        if ( top_window ) {
            size_t window_text_len = static_cast<size_t>(GetWindowTextLength(top_window));

            if ( window_text_len ) {
                std::unique_ptr<char[]> test_name(new char[window_text_len]);

                if ( GetWindowText(top_window, test_name.get(), static_cast<int>(window_text_len)) ) {
                    std::string window_text_name = test_name.get();

                    if ( window_text_name.find("WinDbg:") != std::string::npos ) {
                        *found = true;
                        return FALSE;  // stop enumeration
                    }
                }
            }
        }
    }

    return TRUE;
}
Ejemplo n.º 10
0
int main(int argc, char** argv) 
{
  // default arguments
  autopilot_parms.bearing_noise=fixed(0);
  autopilot_parms.target_noise=fixed(0.1);
  autopilot_parms.turn_speed=fixed(5.0);
  output_skip = 5;

  if (!parse_args(argc,argv)) {
    return 0;
  }

#define NUM_TESTS 2

  plan_tests(NUM_TESTS);

  for (int j=0; j<NUM_TESTS; j++) {
    unsigned i = rand()%NUM_WIND;

    if (j+1==NUM_TESTS) {
      verbose=1;
    }
    ok (test_flight_times(7,i), test_name("flight times",7,i),0);
  }
  return exit_status();
}
Ejemplo n.º 11
0
static int test_invalid_base(void) {
  struct r2fa_totp_cfg cfg;
  char code[] = "qwerty", key[] = "12345678901234567890", base[] = "0123456789ABCDEF";
  int ret;

  test_name("totp: test_invalid_base");
  r2fa_totp_init(&cfg);

  cfg.key = key;
  cfg.key_len = sizeof(key);
  cfg.output_base = base;

  ret = r2fa_totp_generate(&cfg, code);
  assert(ret == R2FA_OATH_INVALID_BASE_LEN);
  cfg.output_base_len = 1;
  ret = r2fa_totp_generate(&cfg, code);
  assert(ret == R2FA_OATH_INVALID_BASE_LEN);

  cfg.output_base_len = sizeof(base);

  ret = r2fa_totp_generate(&cfg, code);
  assert(ret == R2FA_OATH_SUCCESS);

  return 1;
}
Ejemplo n.º 12
0
Archivo: dec.c Proyecto: wormt/bcc
void s_test_var( struct semantic* semantic, struct var* var ) {
   if ( test_spec( semantic, var ) ) {
      test_name( semantic, var );
      if ( test_dim( semantic, var ) ) {
         var->object.resolved = test_initz( semantic, var );
      }
   }
}
Ejemplo n.º 13
0
static void print_tests(void) {
	const struct test_suite *test;
	int i = 0;

	test_foreach(test) {
		printf("%3d. %s\n", ++i, test_name(test));
	}
	printf("\nTotal tests: %d\n", i);
}
Ejemplo n.º 14
0
inline void run_test(const char* name)
{
  test_name() = name;
  long errors_before = boost::asio::detail::test_errors();
  Test();
  if (test_errors() == errors_before)
    BOOST_ASIO_TEST_IOSTREAM << name << " passed" << std::endl;
  else
    BOOST_ASIO_TEST_IOSTREAM << name << " failed" << std::endl;
}
Ejemplo n.º 15
0
// ----------------------------------------------------------------------------
//
void DefinitionReader::readFixtureDefinitions( LPCSTR directory )
{
    CFileFind finder;
    
    CString directory_search( directory );
    directory_search.Append( "\\*" );

    BOOL working = finder.FindFile( directory_search );
    if ( !working ) 
        throw StudioException( "Unable to find fixture definition directory '%s'", directory );

    while ( working ) {
        working = finder.FindNextFile();
        if ( finder.IsDots() )
            continue;

        CString file_name = finder.GetFilePath();
        if ( finder.IsDirectory() )
            readFixtureDefinitions( file_name );

        CString test_name( file_name );
        if ( test_name.MakeLower().Find( ".xml" ) == -1 )
            continue;

        // Check for definition file
        TiXmlDocument doc;
        if ( !doc.LoadFile( file_name ) )
            throw StudioException( "Error reading fixture definition '%s'", file_name );

        try {
            TiXmlElement* root = doc.FirstChildElement( "fixture_definitions" );
            LPCSTR author = read_text_element( root, "author" );
            LPCSTR version = read_text_element( root, "version" );

            FixtureDefinitionPtrArray fixture_definitions = read_xml_list<FixtureDefinition>( root, "fixture" );

            //DefinitionWriter writer;
            //writer.writeFixtureDefinition( file_name, author, version, fixture_definitions );

            for ( FixtureDefinition* definition : fixture_definitions ) {
                definition->setSourceFile( file_name );
                definition->m_author = author;
                definition->m_version = version;

                FixtureDefinition::addFixtureDefinition( definition );
                delete definition;
            }
        }
        catch ( StudioException e ) {
            throw StudioException( "%s: %s", file_name, e.what() );
        }
    }
    
    finder.Close();
}
Ejemplo n.º 16
0
int main(int argc, char** argv)
{
  if (!parse_args(argc,argv)) {
    return 0;
  }

  #define NUM_RANDOM 50
  #define NUM_TYPE_MANIPS 50
  plan_tests(NUM_TASKS+2+NUM_RANDOM+8+NUM_TYPE_MANIPS);

  GlidePolar glide_polar(fixed_two);

  Waypoints waypoints;
  setup_waypoints(waypoints);

  {
    TaskManager task_manager(waypoints);
    task_manager.SetGlidePolar(glide_polar);
    test_task_bad(task_manager,waypoints);
  }

  {
    for (unsigned i = 0; i < NUM_TYPE_MANIPS; i++) {
      TaskManager task_manager(waypoints);
      ok(test_task_type_manip(task_manager,waypoints, i+2), "construction: task type manip", 0);
    }
  }

  for (int i=0; i<NUM_TASKS+2; i++) {
    TaskManager task_manager(waypoints);
    task_manager.SetGlidePolar(glide_polar);
    ok(test_task(task_manager, waypoints, i),test_name("construction",i,0),0);
  }

  for (int i=0; i<NUM_RANDOM; i++) {
    TaskManager task_manager(waypoints);
    task_manager.SetGlidePolar(glide_polar);
    ok(test_task(task_manager, waypoints, 7),test_name("construction",7,0),0);
  }

  return exit_status();
}
Ejemplo n.º 17
0
const struct test_suite *test_lookup(const char *name) {
	const struct test_suite *test = NULL;

	test_foreach(test) {
		if (strcmp(test_name(test), name) == 0) {
			return test;
		}
	}

	return NULL;
}
Ejemplo n.º 18
0
void test_aux (void)
{
	dbg_printf ("Auxiliary functions ");
	if (trace)
		fflush (stdout);
	test_ee ();
	test_constr ();
	test_name ();
	test_sched ();
	test_err ();
	dbg_printf (" - success!\r\n");
}
Ejemplo n.º 19
0
int
main (int   argc,
      char *argv[])
{
	/* run tests in legacy (pre-session support) mode */
	setenv ("UPSTART_NO_SESSIONS", "1", 1);

	test_new ();

	test_name ();
	test_from_name ();

	return 0;
}
Ejemplo n.º 20
0
int main (int argc, char ** argv)
{
	printf (" PLUGINS  TESTS\n");
	printf ("====================\n\n");

	init (argc, argv);

	test_process ();
	test_simple ();
	test_name ();

	printf ("\ntest_plugin RESULTS: %d test(s) done. %d error(s).\n", nbTest, nbError);

	return nbError;
}
Ejemplo n.º 21
0
int main(int argc, char** argv) 
{
  // default arguments
  autopilot_parms.ideal();

  if (!parse_args(argc,argv)) {
    return 0;
  }

  plan_tests(NUM_TASKS);

  for (int j=0; j<NUM_TASKS; j++) {
    unsigned k = rand()%NUM_WIND;
    ok (test_flight_times(j,k), test_name("flight times",j,k),0);
  }
  return exit_status();
}
Ejemplo n.º 22
0
int main (int argc, char ** argv)
{
	printf ("  RESOLVER  TESTS\n");
	printf ("====================\n\n");

	init (argc, argv);

	test_resolve ();
	test_name ();
	test_lockname ();
	test_tempname ();
	test_checkfile ();


	printf ("\ntest_backendhelpers RESULTS: %d test(s) done. %d error(s).\n", nbTest, nbError);

	return nbError;
}
Ejemplo n.º 23
0
void mm_run_tests()
{
    test_id();
    test_object_id();
    test_init();
    test_spatial();
    test_object_add_remove_properties();
    test_name();
    test_social_meet();
    test_som();
    test_communicate_social_categorisation();
    test_episodic();
    test_tale();
    test_narratives();
    test_confabulation_with_narratives();
    test_confabulation_with_episodic();

    printf("All tests passed\n");
}
Ejemplo n.º 24
0
static bool
test_automc(int test_num, int n_wind)
{
  // test whether flying by automc (starting above final glide)
  // arrives home faster than without

  TestFlightResult result = test_flight(test_num, n_wind, 1.0, false);
  double t0 = result.time_elapsed;

  result = test_flight(test_num, n_wind, 1.0, true);
  double t1 = result.time_elapsed;

  bool fine = (t1 / t0 < 1.015);
  if (!fine || verbose)
    printf("# time ratio %g\n", t1 / t0);

  ok(fine, test_name("faster with auto mc on", test_num, n_wind), 0);

  return fine;
}
static int ims_test(FILE *f, char *t, const int start)
{
    int i;
    int smp_size, pat;
    struct ims_header ih;

    smp_size = 0;

    fread(&ih.title, 20, 1, f);

    for (i = 0; i < 31; i++) {
	if (fread(&ih.ins[i].name, 1, 20, f) < 20)
	    return -1;

	ih.ins[i].finetune = (int16)read16b(f);
	ih.ins[i].size = read16b(f);
	ih.ins[i].unknown = read8(f);
	ih.ins[i].volume = read8(f);
	ih.ins[i].loop_start = read16b(f);
	ih.ins[i].loop_size = read16b(f);

	smp_size += ih.ins[i].size * 2;

	if (test_name(ih.ins[i].name, 20) < 0)
	    return -1;

	if (ih.ins[i].volume > 0x40)
	    return -1;

	if (ih.ins[i].size > 0x8000)
	    return -1;

	if (ih.ins[i].loop_start > ih.ins[i].size)
	    return -1;

        if (ih.ins[i].size && ih.ins[i].loop_size > 2 * ih.ins[i].size)
	    return -1;
    }

    if (smp_size < 8)
	return -1;

    ih.len = read8(f);
    ih.zero = read8(f);
    fread (&ih.orders, 128, 1, f);
    fread (&ih.magic, 4, 1, f);
  
    if (ih.zero > 1)		/* not sure what this is */
	return -1;

    if (ih.magic[3] != 0x3c)
	return -1;

    if (ih.len > 0x7f)
	return -1;

    for (pat = i = 0; i < ih.len; i++)
	if (ih.orders[i] > pat)
	    pat = ih.orders[i];
    pat++;

    if (pat > 0x7f || ih.len == 0 || ih.len > 0x7f)
	return -1;
   
    fseek(f, start + 0, SEEK_SET);
    read_title(f, t, 20);

    return 0;
}
Ejemplo n.º 26
0
static bool
test_cruise_efficiency(int test_num, int n_wind)
{
  // tests functionality of cruise efficiency calculations

  double ce0, ce1, ce2, ce3, ce4, ce5, ce6;

  autopilot_parms.ideal();

  TestFlightResult result = test_flight(test_num, n_wind);
  ce0 = result.calc_cruise_efficiency;

  // wandering
  autopilot_parms.realistic();
  result = test_flight(test_num, n_wind);
  ce1 = result.calc_cruise_efficiency;
  // cruise efficiency of this should be lower than nominal
  if (ce0 <= ce1 || verbose)
    printf("# calc cruise efficiency %g\n", result.calc_cruise_efficiency);

  ok(ce0 > ce1, test_name("ce wandering", test_num, n_wind), 0);

  // flying too slow
  autopilot_parms.ideal();
  result = test_flight(test_num, n_wind, 0.8);
  ce2 = result.calc_cruise_efficiency;
  // cruise efficiency of this should be lower than nominal
  if (ce0 <= ce2 || verbose)
    printf("# calc cruise efficiency %g\n", result.calc_cruise_efficiency);

  ok(ce0 > ce2, test_name("ce speed slow", test_num, n_wind), 0);

  // flying too fast
  autopilot_parms.ideal();
  result = test_flight(test_num, n_wind, 1.2);
  ce3 = result.calc_cruise_efficiency;
  // cruise efficiency of this should be lower than nominal
  if (ce0 <= ce3 || verbose)
    printf("# calc cruise efficiency %g\n", result.calc_cruise_efficiency);

  ok(ce0 > ce3, test_name("ce speed fast", test_num, n_wind), 0);

  // higher than expected cruise sink
  autopilot_parms.sink_factor = fixed(1.2);
  result = test_flight(test_num, n_wind);
  ce4 = result.calc_cruise_efficiency;
  if (ce0 <= ce4 || verbose)
    printf("# calc cruise efficiency %g\n", result.calc_cruise_efficiency);

  ok(ce0 > ce4, test_name("ce high sink", test_num, n_wind), 0);
  // cruise efficiency of this should be lower than nominal
  autopilot_parms.sink_factor = fixed(1.0);

  // slower than expected climb
  autopilot_parms.climb_factor = fixed(0.8);
  result = test_flight(test_num, n_wind);
  ce5 = result.calc_cruise_efficiency;
  if (ce0 <= ce5 || verbose)
    printf("# calc cruise efficiency %g\n", result.calc_cruise_efficiency);

  ok(ce0 > ce5, test_name("ce slow climb", test_num, n_wind), 0);
  // cruise efficiency of this should be lower than nominal
  autopilot_parms.climb_factor = fixed(1.0);

  // lower than expected cruise sink;
  autopilot_parms.sink_factor = fixed(0.8);
  result = test_flight(test_num, n_wind);
  ce6 = result.calc_cruise_efficiency;
  if (ce0 >= ce6 || verbose)
    printf("# calc cruise efficiency %g\n", result.calc_cruise_efficiency);

  ok(ce0 < ce6, test_name("ce low sink", test_num, n_wind), 0);
  // cruise efficiency of this should be greater than nominal
  autopilot_parms.sink_factor = fixed(1.0);

  bool retval = (ce0 > ce1) && (ce0 > ce2) && (ce0 > ce3) && (ce0 > ce4)
      && (ce0 > ce5) && (ce0 < ce6);
  if (verbose || !retval) {
    printf("# ce nominal %g\n", ce0);
    printf("# ce wandering %g\n", ce1);
    printf("# ce speed slow %g\n", ce2);
    printf("# ce speed fast %g\n", ce3);
    printf("# ce high sink %g\n", ce4);
    printf("# ce slow climb %g\n", ce5);
    printf("# ce low sink %g\n", ce6);
  }
  return retval;
}
Ejemplo n.º 27
0
int
Tree_Test::execute (TAO_Naming_Client &root_context)
{
  try
    {
      // Create a tree of contexts: root->level1->level2.  Bind object
      // foo under context level2.

      // Bind level1 context under root.
      CosNaming::Name level1;
      level1.length (1);
      level1[0].id = CORBA::string_dup ("level1_context");
      CosNaming::NamingContext_var level1_context;
      level1_context = root_context->bind_new_context (level1);

      // Create a new context.
      CosNaming::NamingContext_var level2_context;
      level2_context = root_context->new_context ();

      // Instantiate a dummy object and bind it under the new context.
      My_Test_Object *impl1 =
        new My_Test_Object (CosNaming_Client::OBJ1_ID);
      Test_Object_var obj1 = impl1->_this ();
      impl1->_remove_ref ();

      CosNaming::Name obj_name;
      obj_name.length (1);
      obj_name[0].id = CORBA::string_dup ("foo");
      level2_context->bind (obj_name, obj1.in ());

      // Bind the context we just created under level1.
      CosNaming::Name level2 (level1);
      level2.length (2);
      level2[1].id = CORBA::string_dup ("level2_context");
      root_context->bind_context (level2,
                                  level2_context.in ());

      // Resolve and unbind level1/level2/foo, and bind it back.
      CosNaming::Name test_name (level2);
      test_name.length (3);
      test_name[2].id = obj_name[0].id;
      CORBA::Object_var result_obj_ref =
        root_context->resolve (test_name);
      Test_Object_var result_object =
        Test_Object::_narrow (result_obj_ref.in ());

      if (CORBA::is_nil (result_object.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Problems with resolving foo in Tree Test - nil object ref.\n"),
                          -1);

      CORBA::Short id = result_object->id ();

      if (id != CosNaming_Client::OBJ1_ID)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Problems with resolving foo in Tree Test - wrong id.\n"),
                          -1);

      // Unbind the object from the Naming Context and bind it back
      // in.
      root_context->unbind (test_name);
      root_context->bind (test_name,
                          obj1.in ());

      // Create new context and rebind under the name level1/level2.
      CosNaming::NamingContext_var new_level2_context;
      new_level2_context =
        root_context->new_context ();
      root_context->rebind_context (level2,
                                  new_level2_context.in ());

      // Bind, resolve, rebind, and resolve foo under level1/level2.
      root_context->bind (test_name,
                          obj1.in ());
      result_obj_ref = root_context->resolve (test_name);
      result_object = Test_Object::_narrow (result_obj_ref.in ());

      CORBA::Short obj_id = result_object->id ();

      if (CORBA::is_nil (result_object.in ())
          || !(obj_id == CosNaming_Client::OBJ1_ID))
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Problems in the Tree Test\n"),
                          -1);

      My_Test_Object *impl2 =
        new My_Test_Object (CosNaming_Client::OBJ2_ID);
      Test_Object_var obj2 = impl2->_this ();

      impl2->_remove_ref ();

      root_context->rebind (test_name,
                            obj2.in ());
      result_obj_ref = root_context->resolve (test_name);
      result_object = Test_Object::_narrow (result_obj_ref.in ());

      obj_id = result_object->id ();

      if (CORBA::is_nil (result_object.in ())
          || !( obj_id == CosNaming_Client::OBJ2_ID))
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Problems with rebind in Tree Test\n"),
                          -1);
    }

  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception (
        "Unexpected exception in Tree test");
      return -1;
    }


  ACE_DEBUG ((LM_DEBUG,
              "All functions work properly\n"));
  return 0;
}
Ejemplo n.º 28
0
GpuTestTask::GpuTestTask(Reporter* reporter,
                         TaskRunner* taskRunner,
                         skiatest::TestRegistry::Factory factory)
    : GpuTask(reporter, taskRunner)
    , fTest(factory(NULL))
    , fName(test_name(fTest->getName())) {}
Ejemplo n.º 29
0
static int test_init_null_ptr(void) {
  int ret = r2fa_totp_init(NULL);
  test_name("totp: test_init_null_ptr");
  assert(ret == R2FA_OATH_CFG_NULL_PTR);
  return 1;
}
Ejemplo n.º 30
0
// virtual
BOOL LLChatBar::handleKeyHere( KEY key, MASK mask )
{
	BOOL handled = FALSE;

	// ALT-RETURN is reserved for windowed/fullscreen toggle
	if( KEY_RETURN == key )
	{
		if (mask == MASK_CONTROL)
		{
			// shout
			sendChat(CHAT_TYPE_SHOUT);
			handled = TRUE;
		}
		else if (mask == MASK_SHIFT)
		{
			// whisper
			sendChat( CHAT_TYPE_WHISPER );	
			handled = TRUE;
		}
		else if (mask == MASK_NONE)
		{
			// say
			sendChat( CHAT_TYPE_NORMAL );
			handled = TRUE;
		}
	}
	// only do this in main chatbar
	else if (KEY_ESCAPE == key && mask == MASK_NONE && gChatBar == this)
	{
		stopChat();
		handled = TRUE;
	}
	else if (key == KEY_TAB)
	{
		if (mInputEditor)
		{
			mInputEditor->deleteSelection(); // Clean up prev completion before attempting a new one
			std::string txt(mInputEditor->getText());

			std::vector<LLUUID> avatar_ids;
			std::vector<LLVector3d> positions;
			LLWorld::getInstance()->getAvatars(&avatar_ids, &positions);

			if (!avatar_ids.empty() && !txt.empty())
			{
				if (mCompletionHolder.cursorPos == -1) // Ele: cache cursor position
					mCompletionHolder.cursorPos = mInputEditor->getCursor();

				if (mCompletionHolder.last_txt != mInputEditor->getText())
				{
					mCompletionHolder.last_txt = std::string(mInputEditor->getText());

					if (mCompletionHolder.cursorPos < (S32)txt.length())
					{
						mCompletionHolder.right = txt.substr(mCompletionHolder.cursorPos);
						mCompletionHolder.left = txt.substr(0, mCompletionHolder.cursorPos);
						mCompletionHolder.match = std::string(mCompletionHolder.left);
					}
					else
					{
						mCompletionHolder.right = "";
						mCompletionHolder.match = std::string(txt);
						mCompletionHolder.left = txt;
					}

					std::string pattern_s = "(^|.*[_=&\\|\\<\\>#@\\[\\]\\-\\+\"',\\.\\?!:;\\*\\(\\)\\s]+)([a-z0-9]+)$";
					boost::match_results<std::string::const_iterator> what;
					boost::regex expression(pattern_s, boost::regex::icase);
					if (boost::regex_search(mCompletionHolder.match, what, expression, boost::match_extra))
					{
						mCompletionHolder.match = what[2];
						if (mCompletionHolder.match.length() < 1)
							return handled;
					}
					else
						return handled;
				}

				mCompletionHolder.names.clear();

				for (U32 i=0; i<avatar_ids.size(); i++)
				{
					if (avatar_ids[i] == gAgent.getID() || avatar_ids[i].isNull())
						continue;

					std::string agent_name = " ";
					std::string agent_surname = " ";

					if(!gCacheName->getName(avatar_ids[i], agent_name, agent_surname) && (agent_name == " " || agent_surname == " "))
						continue;

					std::string test_name(agent_name);
					std::transform(test_name.begin(), test_name.end(), test_name.begin(), tolower);
					std::transform(mCompletionHolder.match.begin(), mCompletionHolder.match.end(), mCompletionHolder.match.begin(), tolower);

					if (test_name.find(mCompletionHolder.match) == 0)
						mCompletionHolder.names.push_back(agent_name);
				}

				if (mCompletionHolder.current_index >= (S32)mCompletionHolder.names.size() || mCompletionHolder.match != mCompletionHolder.last_match)
				{
					mCompletionHolder.current_index = 0;
					mCompletionHolder.last_match = mCompletionHolder.match;
				}

				if (mCompletionHolder.names.size() > 0)
				{
					std::string current_name = mCompletionHolder.names[mCompletionHolder.current_index];

					mInputEditor->setText(mCompletionHolder.left.substr(0, mCompletionHolder.left.length() - mCompletionHolder.match.length()) + current_name + mCompletionHolder.right);
					mInputEditor->setCursor(mCompletionHolder.cursorPos + (current_name.length() - mCompletionHolder.match.length()));
					mInputEditor->setSelection(mCompletionHolder.cursorPos, mCompletionHolder.cursorPos + (current_name.length() - mCompletionHolder.match.length()));

					mCompletionHolder.current_index++;
					mCompletionHolder.selected = TRUE;

					return TRUE;
				}
			}
		}
	}

	return handled;
}