blob: 142b20e5aec16f71a58bf1a7f4443d32109e8ac9 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001#include "Perforce.h"
2#include <stdio.h>
3
4static int
5RunCommand_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
13static int
14GetResourceFileNames_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
41static int
42GetFile_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
50int
51Perforce_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