Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / tests / IDLv4 / annotations / Annotation_Test.h
blobd5e351c0dd453c6e34cae2c41608bc5a9736647b
1 #include <ast_annotation_decl.h>
2 #include <ast_annotation_member.h>
3 #include <utl_identifier.h>
4 #include <ast_generator.h>
5 #include <utl_scope.h>
6 #include <fe_declarator.h>
7 #include <ast_field.h>
8 #include <ast_typedef.h>
9 #include <ast_sequence.h>
10 #include <ast_union.h>
11 #include <ast_enum_val.h>
12 #include <utl_string.h>
13 #include <ast_array.h>
14 #include <ast_interface.h>
16 #include <ace/OS_NS_stdlib.h>
17 #include <ace/OS_NS_string.h>
18 #include <ace/OS_NS_stdio.h>
19 #ifndef ACE_LACKS_IOSTREAM_TOTALLY
20 # include <ace/streams.h>
21 #endif
23 #include <string>
25 struct Failed {};
27 class Annotation_Test {
28 public:
29 std::string name_;
30 std::string idl_;
31 bool failed_;
32 int error_count_;
33 UTL_Error::ErrorCode last_error_, last_warning_;
34 UTL_Scope *scope_;
35 bool disable_output_;
37 static unsigned failed_test_count_;
38 static unsigned total_test_count_;
40 explicit Annotation_Test (const std::string &name);
42 ~Annotation_Test ();
44 void failed (const std::string &message = "");
46 Annotation_Test &error_count (int error_count);
48 Annotation_Test &last_error (UTL_Error::ErrorCode last_error);
50 Annotation_Test &last_warning (UTL_Error::ErrorCode last_warning);
52 Annotation_Test &run (const std::string &idl);
54 AST_Decl *assert_node (const char *name, UTL_Scope *from = 0);
56 template <typename T>
57 T *assert_node (const char *name, UTL_Scope *from = 0)
59 T *cast = dynamic_cast<T *> (assert_node (name, from));
60 if (!cast)
62 ACE_ERROR ((LM_ERROR,
63 ACE_TEXT ("Annotation Test Error: %C:\n")
64 ACE_TEXT ("assert_node: Failed to cast node to requested type!\n"),
65 name_.c_str ()));
66 failed ();
68 return cast;
71 AST_Annotation_Decl *assert_annotation_decl (const char *name);
73 void assert_annotation_appl_count (AST_Decl *node, size_t count);
75 AST_Annotation_Appl *assert_annotation_appl (
76 AST_Decl *node, size_t index, AST_Annotation_Decl *anno_decl);
78 void assert_annotation_member_count (
79 AST_Annotation_Decl *anno_decl, size_t count);
81 void assert_annotation_member_count (
82 AST_Annotation_Appl *anno_appl, size_t count);
84 AST_Annotation_Member *get_annotation_member (
85 AST_Annotation_Decl *anno_decl, const char *name);
87 AST_Annotation_Member *get_annotation_member (
88 AST_Annotation_Appl *anno_appl, const char *name);
90 void assert_annotation_member_type (
91 AST_Annotation_Member *member, AST_Expression::ExprType type);
93 void assert_annotation_member_value (
94 AST_Annotation_Member *member, AST_Expression *expected);
96 template <typename T1, typename T2>
97 void assert_annotation_member_value (
98 AST_Annotation_Member *member, T1 expected_value)
100 AST_Expression expected (static_cast<T2> (expected_value));
101 assert_annotation_member_value (member, &expected);
104 void assert_annotation_member_no_value (AST_Annotation_Member *member);
106 void set_scope (AST_Decl *scope_node);
108 void disable_output ();
110 void print_idl_with_line_numbers ();
112 static void results ();