forked from osmc/osmc
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PATCH] kodi-test: add test cases for CSysfsPath
- Loading branch information
1 parent
cfe6288
commit 160d6f9
Showing
1 changed file
with
76 additions
and
0 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
package/mediacenter-next-osmc/patches/rbp-301-CSysfsPatch.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
From 7683a1dd08735246653d59069b6f80eeb0d1f82a Mon Sep 17 00:00:00 2001 | ||
From: Lukas Rusak <lorusak@gmail.com> | ||
Date: Wed, 8 May 2019 22:44:17 -0700 | ||
Subject: [PATCH] kodi-test: add test cases for CSysfsPath | ||
|
||
--- | ||
cmake/treedata/linux/tests.txt | 1 + | ||
xbmc/platform/linux/test/CMakeLists.txt | 3 ++ | ||
xbmc/platform/linux/test/TestSysfsPath.cpp | 40 ++++++++++++++++++++++ | ||
3 files changed, 44 insertions(+) | ||
create mode 100644 cmake/treedata/linux/tests.txt | ||
create mode 100644 xbmc/platform/linux/test/CMakeLists.txt | ||
create mode 100644 xbmc/platform/linux/test/TestSysfsPath.cpp | ||
|
||
diff --git a/cmake/treedata/linux/tests.txt b/cmake/treedata/linux/tests.txt | ||
new file mode 100644 | ||
index 000000000000..3f3a3e35fd6a | ||
--- /dev/null | ||
+++ b/cmake/treedata/linux/tests.txt | ||
@@ -0,0 +1 @@ | ||
+xbmc/platform/linux/test platform/linux/test | ||
diff --git a/xbmc/platform/linux/test/CMakeLists.txt b/xbmc/platform/linux/test/CMakeLists.txt | ||
new file mode 100644 | ||
index 000000000000..1fb0281ce033 | ||
--- /dev/null | ||
+++ b/xbmc/platform/linux/test/CMakeLists.txt | ||
@@ -0,0 +1,3 @@ | ||
+list(APPEND SOURCES TestSysfsPath.cpp) | ||
+ | ||
+core_add_test_library(linux_test) | ||
diff --git a/xbmc/platform/linux/test/TestSysfsPath.cpp b/xbmc/platform/linux/test/TestSysfsPath.cpp | ||
new file mode 100644 | ||
index 000000000000..9d8171bc6052 | ||
--- /dev/null | ||
+++ b/xbmc/platform/linux/test/TestSysfsPath.cpp | ||
@@ -0,0 +1,40 @@ | ||
+/* | ||
+ * Copyright (C) 2005-2018 Team Kodi | ||
+ * This file is part of Kodi - https://kodi.tv | ||
+ * | ||
+ * SPDX-License-Identifier: GPL-2.0-or-later | ||
+ * See LICENSES/README.md for more information. | ||
+ */ | ||
+ | ||
+#include "platform/linux/SysfsPath.h" | ||
+ | ||
+#include <fstream> | ||
+ | ||
+#include <gtest/gtest.h> | ||
+ | ||
+struct TestSysfsPath : public ::testing::Test | ||
+{ | ||
+ ~TestSysfsPath() { std::remove("/tmp/kodi-test"); } | ||
+}; | ||
+ | ||
+TEST_F(TestSysfsPath, SysfsPathTest) | ||
+{ | ||
+ int temp{1234}; | ||
+ std::ofstream output{"/tmp/kodi-test"}; | ||
+ output << temp; | ||
+ output.close(); | ||
+ | ||
+ CSysfsPath path("/tmp/kodi-test"); | ||
+ ASSERT_TRUE(path.Exists()); | ||
+ ASSERT_TRUE(path.Get<int>() == 1234); | ||
+ ASSERT_TRUE(path.Get<float>() == 1234); | ||
+ ASSERT_TRUE(path.Get<double>() == 1234); | ||
+ ASSERT_TRUE(path.Get<uint64_t>() == 1234); | ||
+ ASSERT_TRUE(path.Get<uint16_t>() == 1234); | ||
+ ASSERT_TRUE(path.Get<unsigned int>() == 1234); | ||
+ ASSERT_TRUE(path.Get<unsigned long int>() == 1234); | ||
+ ASSERT_TRUE(path.Get<std::string>() == "1234"); | ||
+ | ||
+ CSysfsPath otherPath{"/thispathdoesnotexist"}; | ||
+ ASSERT_FALSE(otherPath.Exists()); | ||
+} |