Synopsis - Cross-Reference

File: /tests/Cxx-API/Python/src/Tuple.cc
 1#include <Synopsis/Python/Object.hh>
 2#include "Guard.hh"
 3#include <string>
 4#include <iostream>
 5
 6using namespace Synopsis::Python;
 7
 8void test1()
 9{
10  List list;
11  list.append('a');
12  list.append(1);
13  list.append("hello");
14  list.append("world");
15  Tuple tuple = list.tuple();
16  std::cout << Object::narrow<const char *>(tuple.str()) << std::endl;
17  Object object(tuple);
18  tuple = Object::narrow<Tuple>(object);
19  std::cout << Object::narrow<const char *>(tuple.str()) << std::endl;
20}
21
22void test2()
23{
24  Tuple t1('1', '2', '3');
25  std::cout << Object::narrow<const char *>(t1.str()) << std::endl;
26  Tuple t2("hello", "world", 42);
27  std::cout << Object::narrow<const char *>(t2.str()) << std::endl;
28}
29
30int main(int, char **)
31{  
32  try
33  {
34    test1();
35    test2();
36  }
37  catch (const std::exception &e)
38  {
39    std::cout << "Error : " << e.what() << std::endl;
40  }
41}