~jheiss/galera/galera

« back to all changes in this revision

Viewing changes to galerautils/tests/gu_uri_test.cpp

  • Committer: Alex Yurchenko
  • Date: 2012-01-16 03:54:07 UTC
  • mto: This revision was merged to the branch mainline in revision 109.
  • Revision ID: ayurchen@void-20120116035407-fnlisz8pubqxh1m5
References lp:915499, lp:907071 - synced with SVN r2671

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// Copyright (C) 2007 Codership Oy <info@codership.com>
2
2
 
3
 
// $Id: gu_uri_test.cpp 2463 2011-10-18 12:33:07Z teemu $
 
3
// $Id: gu_uri_test.cpp 2667 2012-01-15 05:36:23Z alex $
4
4
 
5
5
#include <cerrno>
6
6
#include <string>
360
360
}
361
361
END_TEST
362
362
 
 
363
START_TEST(uri_non_strict)
 
364
{
 
365
    std::string const ip("1.2.3.4");
 
366
    std::string const port("789");
 
367
    std::string const addr(ip + ':' + port);
 
368
 
 
369
    try
 
370
    {
 
371
        URI u(ip);
 
372
        fail("Strict mode passed without scheme");
 
373
    }
 
374
    catch (gu::Exception& e)
 
375
    {
 
376
        fail_if (e.get_errno() != EINVAL, "Expected errno %d, got %d",
 
377
                 EINVAL, e.get_errno());
 
378
    }
 
379
 
 
380
    try
 
381
    {
 
382
        URI u(addr, false);
 
383
 
 
384
        fail_if (u.get_host() != ip);
 
385
        fail_if (u.get_port() != port);
 
386
 
 
387
        try
 
388
        {
 
389
            u.get_scheme();
 
390
            fail("Scheme is '%s', should be unset", u.get_scheme().c_str());
 
391
        }
 
392
        catch (gu::NotSet&) {}
 
393
    }
 
394
    catch (gu::Exception& e)
 
395
    {
 
396
        fail_if (e.get_errno() != EINVAL);
 
397
    }
 
398
}
 
399
END_TEST
 
400
 
363
401
Suite *gu_uri_suite(void)
364
402
{
365
403
  Suite *s  = suite_create("galerautils++ URI");
369
407
  tcase_add_test  (tc, uri_test1);
370
408
  tcase_add_test  (tc, uri_test2);
371
409
  tcase_add_test  (tc, uri_test3);
 
410
  tcase_add_test  (tc, uri_non_strict);
372
411
  return s;
373
412
}
374
413