headers/bsd: Add sys/queue.h.
[haiku.git] / src / tests / add-ons / print / ppd / test / Test.cpp
blob07ddfd604aa564d435d2f5324fb3b8d994a7c403
1 /*
2 * Copyright 2008, Haiku.
3 * Distributed under the terms of the MIT license.
5 * Authors:
6 * Michael Pfeiffer <laplace@users.sourceforge.net>
7 */
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <string.h>
12 #include <List.h>
14 void TestScanner();
15 void TestParser();
16 void TestPPDParser(bool all, bool verbose = true);
17 void TestExtractUI();
19 const char* gPPDFile = "aptollw1.ppd";
21 static BList gArgs;
23 bool enabled(const char* name, const char* arg)
25 gArgs.AddItem((void*)name);
26 if (arg == NULL) return false;
27 if (strcmp(arg, "all") == 0) return true;
28 return strcmp(arg, name) == 0;
31 void printArgs(const char* programName)
33 fprintf(stderr, "%s: argument\n", programName);
34 fprintf(stderr, "Argument is missing. The available arguments are:\n");
35 fprintf(stderr, " all\n");
36 for (int i = 0; i < gArgs.CountItems(); i ++) {
37 fprintf(stderr, " %s\n", (const char*)gArgs.ItemAt(i));
41 int main(int argc, char* argv[])
43 const char* arg = argc >= 2 ? argv[1] : NULL;
45 if (argc >= 3) {
46 gPPDFile = argv[2];
49 if (enabled("scanner", arg)) {
50 TestScanner();
52 if (enabled("parser", arg)) {
53 TestParser();
55 if (enabled("ppd", arg)) {
56 TestPPDParser(true);
58 if (enabled("header", arg)) {
59 TestPPDParser(false);
61 if (enabled("ui", arg)) {
62 TestExtractUI();
64 if (enabled("ppd-timing", arg)) {
65 TestPPDParser(true, false);
67 if (enabled("header-timing", arg)) {
68 TestPPDParser(false, false);
71 if (arg == NULL) {
72 printArgs(argv[0]);