loc_test.C 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: loc_test.C /main/5 1996/10/26 18:19:23 cde-hal $ */
  24. #ifdef REGRESSION_TEST
  25. #include "oliasdb/loc_test.h"
  26. #define LARGE_BUFSIZ 2048
  27. void print_loc(locator_smart_ptr& x, ostream& out)
  28. {
  29. out << x.inside_node_locator_str();
  30. x.node_id().asciiOut(out); out << "\n";
  31. }
  32. int compare_locator(locator_smart_ptr& pattern, info_base* base_ptr)
  33. {
  34. char pattern_buf[LARGE_BUFSIZ];
  35. ostringstream pattern_out(pattern_buf, LARGE_BUFSIZ, ios::out);
  36. print_loc(pattern, pattern_out);
  37. locator_smart_ptr x( base_ptr, pattern.inside_node_locator_str());
  38. char db_buf[LARGE_BUFSIZ];
  39. ostringstream db_out(db_buf, LARGE_BUFSIZ, ios::out);
  40. print_loc(x, db_out);
  41. return compare_stream(pattern_out, db_out);
  42. }
  43. int loc_test( info_lib* infolib_ptr, const char* base_name, const char* loc )
  44. {
  45. locator_smart_ptr x( infolib_ptr, base_name, loc );
  46. print_loc(x, cerr);
  47. return 0;
  48. }
  49. void generate_loc_instance(random_gen& x, ostream& out)
  50. {
  51. out << "1002\n";
  52. out << "3\n";
  53. x.random_string(out, 15, 15); // locator
  54. x.random_oid(out, 1001, 0); // id
  55. x.random_string(out, 8, 255); // label
  56. }
  57. #endif