diff options
author | Michele Calgaro <[email protected]> | 2021-11-20 17:25:17 +0900 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2021-11-20 17:25:17 +0900 |
commit | 652c2aea23bd9dea082f5de2c0babe1728ac608f (patch) | |
tree | 3e649e665e3b073d2017f727fa0515f27474abd2 /tests/test_subject.cpp | |
parent | 1200d940add87b767246e45080e25ed207eee014 (diff) | |
download | polkit-tqt-652c2aea23bd9dea082f5de2c0babe1728ac608f.tar.gz polkit-tqt-652c2aea23bd9dea082f5de2c0babe1728ac608f.zip |
Added test framework.
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'tests/test_subject.cpp')
-rw-r--r-- | tests/test_subject.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/test_subject.cpp b/tests/test_subject.cpp new file mode 100644 index 000000000..b07317ec5 --- /dev/null +++ b/tests/test_subject.cpp @@ -0,0 +1,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; +} |