Perforce_test.cpp revision 54b6cfa9a9e5b861a9930af873580d6dc20f773c
1#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
63