1 #include "Perforce.h"
2 #include <stdio.h>
3
4 static int
RunCommand_test()5 RunCommand_test()
6 {
7 string result;
8 int err = Perforce::RunCommand("p4 help csommands", &result, true);
9 printf("err=%d result=[[%s]]\n", err, result.c_str());
10 return 0;
11 }
12
13 static int
GetResourceFileNames_test()14 GetResourceFileNames_test()
15 {
16 vector<string> results;
17 vector<string> apps;
18 apps.push_back("apps/common");
19 apps.push_back("apps/Contacts");
20 int err = Perforce::GetResourceFileNames("43019", "//device", apps, &results, true);
21 if (err != 0) {
22 return err;
23 }
24 if (results.size() != 2) {
25 return 1;
26 }
27 if (results[0] != "//device/apps/common/res/values/strings.xml") {
28 return 1;
29 }
30 if (results[1] != "//device/apps/Contacts/res/values/strings.xml") {
31 return 1;
32 }
33 if (false) {
34 for (size_t i=0; i<results.size(); i++) {
35 printf("[%zd] '%s'\n", i, results[i].c_str());
36 }
37 }
38 return 0;
39 }
40
41 static int
GetFile_test()42 GetFile_test()
43 {
44 string result;
45 int err = Perforce::GetFile("//device/Makefile", "296", &result, true);
46 printf("err=%d result=[[%s]]\n", err, result.c_str());
47 return 0;
48 }
49
50 int
Perforce_test()51 Perforce_test()
52 {
53 bool all = false;
54 int err = 0;
55
56 if (all) err |= RunCommand_test();
57 if (all) err |= GetResourceFileNames_test();
58 if (all) err |= GetFile_test();
59
60 return err;
61 }
62
63