~ubuntu-branches/ubuntu/wily/afnix/wily

« back to all changes in this revision

Viewing changes to src/lib/std/tst/obj/t_quarktable.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anibal Monsalve Salazar
  • Date: 2011-03-16 21:31:18 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110316213118-gk4k3ez3e5d2huna
Tags: 2.0.0-1
* QA upload.
* New upstream release
* Debian source format is 3.0 (quilt)
* Fix debhelper-but-no-misc-depends
* Fix ancient-standards-version
* Fix package-contains-linda-override
* debhelper compatibility is 7
* Fix dh-clean-k-is-deprecated

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// ---------------------------------------------------------------------------
2
 
// - t_quarktable.cpp                                                        -
3
 
// - standard object library - quark table class tester                      -
4
 
// ---------------------------------------------------------------------------
5
 
// - This program is free software;  you can redistribute it  and/or  modify -
6
 
// - it provided that this copyright notice is kept intact.                  -
7
 
// -                                                                         -
8
 
// - This program  is  distributed in  the hope  that it will be useful, but -
9
 
// - without  any  warranty;  without  even   the   implied    warranty   of -
10
 
// - merchantability or fitness for a particular purpose.  In no event shall -
11
 
// - the copyright holder be liable for any  direct, indirect, incidental or -
12
 
// - special damages arising in any way out of the use of this software.     -
13
 
// ---------------------------------------------------------------------------
14
 
// - copyright (c) 1999-2007 amaury darsch                                   -
15
 
// ---------------------------------------------------------------------------
16
 
 
17
 
#include "QuarkTable.hpp"
18
 
 
19
 
int main (int, char**) {
20
 
  using namespace afnix;
21
 
 
22
 
  QuarkTable* qtable = new QuarkTable (2);
23
 
  String*     hello  = new String ("hello");
24
 
  String*     world  = new String ("world");
25
 
  String*     sfo    = new String ("from sfo");
26
 
  Object*     object = nilp;
27
 
  String*     strobj = nilp;
28
 
 
29
 
  // insert out favorite message
30
 
  qtable->add (hello->toquark (), Object::iref (hello));
31
 
  if (qtable->length  ()  != 1)       return 1;
32
 
  if (qtable->getname (0) != "hello") return 1;  
33
 
  if (qtable->getobj  (0) != hello)   return 1;
34
 
  
35
 
  // add more and check
36
 
  qtable->add (world->toquark (), Object::iref (world));
37
 
  qtable->add (sfo->toquark   (), Object::iref (sfo));
38
 
  if (qtable->length () != 3) return 1;
39
 
  
40
 
  // check for our keys
41
 
  if (qtable->exists (hello->toquark ()) == false) return 1;
42
 
  if (qtable->exists (world->toquark ()) == false) return 1;
43
 
  if (qtable->exists (sfo->toquark ())   == false) return 1;
44
 
 
45
 
  // get the first key
46
 
  object = qtable->get (hello->toquark ());
47
 
  strobj = dynamic_cast <String*> (object);
48
 
 
49
 
  // check for string
50
 
  if (strobj  == nilp)    return 1;
51
 
  if (*strobj != "hello") return 1;
52
 
 
53
 
  // get the second key
54
 
  object = qtable->get (world->toquark ());
55
 
  strobj = dynamic_cast <String*> (object);
56
 
  if (strobj  == nilp)    return 1;
57
 
  if (*strobj != "world") return 1;
58
 
 
59
 
  // remove a key
60
 
  qtable->remove (hello->toquark ());
61
 
  if (qtable->exists (hello->toquark ()) == true) return 1;
62
 
 
63
 
  // delete everything
64
 
  delete qtable;
65
 
  Object::dref (hello);
66
 
  Object::dref (world);
67
 
  Object::dref (sfo);
68
 
  return 0;
69
 
}