PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
FunctionMapTest.cpp File Reference
#include "../base/PNode.h"
#include "../base/FunctionMap.h"
#include "../base/Variant.h"
#include "../base/grammar.tab.hpp"
#include <iostream>
#include <stdio.h>

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 37 of file FunctionMapTest.cpp.

38{
39
40 using std::cout;
41 using std::endl;
42 using std::flush;
43
44 long int a = 12341;
45 long double b = 3352.9933;
46
47 cout << "\n\n\n==========================================================\n";
48 cout << "Testing the FunctionMap Class\n";
49 cout << "==========================================================\n";
50
51
52 cout << "\n\n\n==========================================================\n";
53 cout << "Making a new FunctionMap\n";
54 cout << "==========================================================\n";
55 FunctionMap myFMap; cout << "." << flush;
56
57 cout << "\n\n\n==========================================================\n";
58 cout << "Making some OpNodes\n";
59 cout << "==========================================================\n";
60 PNode *myPNode1 = new OpNode(PEBL_ADD,0,0); cout << "." << flush;
61 PNode *myPNode2 = new OpNode(PEBL_DIVIDE,0,0); cout << "." << flush;
62 PNode *myPNode3 = new OpNode(PEBL_ELSE, 0,0); cout << "." << flush;
63 PNode *myPNode4 = new OpNode(PEBL_GE,0,0); cout << "." << flush;
64 PNode *myPNode5 = new OpNode(PEBL_EQ,0,0); cout << "." << flush;
65 PNode *myPNode6;
66
67 cout << *myPNode1 << endl;
68 cout << *myPNode2 << endl;
69 cout << *myPNode3 << endl;
70 cout << *myPNode4 << endl;
71 cout << *myPNode5 << endl;
72
73 cout << "\n\n\n==========================================================\n";
74 cout << "Adding nodes to map\n";
75 cout << "==========================================================\n";
76 myFMap.AddFunction("one", (OpNode*)myPNode1); cout << "." << flush;
77 myFMap.AddFunction("two",(OpNode*)myPNode2); cout << "." << flush;
78 myFMap.AddFunction("four",(OpNode*)myPNode3); cout << "." << flush;
79 myFMap.AddFunction("four", (OpNode*)myPNode4); cout << "." << flush;
80 myFMap.AddFunction("four", (OpNode*)myPNode5); cout << "." << flush;
81
82 cout << "\n\n\n==========================================================\n";
83 cout << "Dumping entire values from map.\n";
84 cout << "==========================================================\n";
85 myFMap.DumpValues();
86
87 cout << "\n\n\n==========================================================\n";
88 cout << "Testing basic retrieval\n";
89 cout << "==========================================================\n";
90 myPNode6 = myFMap.GetFunction("four");
91 cout << " Retrieved four: " << *myPNode6 << endl;
92
93 myPNode6 = myFMap.GetFunction("two");
94 cout << " Retrieved two: " << *myPNode6 << endl;
95
96 myPNode6 = myFMap.GetFunction("one");
97 cout << " Retrieved one: " << *myPNode6 << endl;
98
99 myPNode6 = myFMap.GetFunction("nobody");
100 cout << " Retrieved nobody: " << *myPNode6 << endl;
101
102
103
104
105 cout << "\n\n\n==========================================================\n";
106 cout << "Testing Deleting\n";
107 cout << "==========================================================\n";
108
109 myFMap.DumpValues(); cout << "--\n";
110
111 cout << "Deleting 'four'" << endl;
112 myFMap.Erase("four"); myFMap.DumpValues();cout << "---------------------------\n";
113 cout << "Deleting 'two'" << endl;
114 myFMap.Erase("two"); myFMap.DumpValues();cout << "---------------------------\n";
115 cout << "Deleting 'one'" << endl;
116 myFMap.Erase("one"); myFMap.DumpValues();cout << "---------------------------\n";
117 cout << "Deleting 'one'" << endl;
118 myFMap.Erase("one"); myFMap.DumpValues();cout << "---------------------------\n";
119 cout << "Deleting 'one'" << endl;
120 myFMap.Erase("one"); myFMap.DumpValues();cout << "---------------------------\n";
121 cout << "Deleting 'four'" << endl;
122 myFMap.Erase("four"); myFMap.DumpValues();cout << "---------------------------\n";
123 cout << "Deleting 'four'" << endl;
124 myFMap.Erase("four"); myFMap.DumpValues();cout << "---------------------------\n";
125
126
127
128
129 cout << "==========================================================\n";
130 cout << "Finished Function Map Tests" << endl;
131 cout << "==========================================================\n";
132 cout << "==========================================================\n";
133 cout << "==========================================================\n";
134 cout << "==========================================================\n";
135 cout << "==========================================================\n";
136 return 0;
137}
void DumpValues()
void AddFunction(std::string funcname, OpNode *node)
PNode * GetFunction(const std::string &funcname)
void Erase(const std::string &funcname)
Definition PNode.h:45

References FunctionMap::AddFunction(), FunctionMap::DumpValues(), FunctionMap::Erase(), and FunctionMap::GetFunction().