summaryrefslogtreecommitdiffstats
path: root/tests/test_subject.cpp
blob: b07317ec5cb1bd62b9762a0f1c006f18138d74aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

#include <unistd.h>
#include <tqstring.h>
#include "core/polkit-tqt-subject.h"

#define TEST_PASSED 0
#define TEST_FAILED 1

using namespace PolkitTQt;

int main(void)
{
  int test_result = TEST_PASSED;

  // Create unix process for current process
  TQ_LONG pid = getpid();
  UnixProcessSubject *process = new UnixProcessSubject(pid);
  if (process->pid() != pid)
  {
    test_result = TEST_FAILED;
  }

  // Serialize and deserialize subject
  Subject subject = Subject::fromString(process->toString());
  if (((UnixProcessSubject*)&subject)->pid() != pid)
  {
    test_result = TEST_FAILED;
  }

  delete process;
  return test_result;
}