aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTinWoodman92 <chrhodgden@gmail.com>2023-07-07 17:27:52 -0500
committerTinWoodman92 <chrhodgden@gmail.com>2023-07-07 17:27:52 -0500
commitb4d5312f01769e5571cef2d1eeff0dea844e054c (patch)
tree2669cc2bbf5de3ae157af97ecb9d769d84e7bea6 /tests
parent589fb6ac0426994c52ffd3aaa3d5233271066789 (diff)
Added tests to compare to alternative packages.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_alt.py43
-rw-r--r--tests/test_alt.r18
2 files changed, 61 insertions, 0 deletions
diff --git a/tests/test_alt.py b/tests/test_alt.py
new file mode 100644
index 0000000..4d4c4a9
--- /dev/null
+++ b/tests/test_alt.py
@@ -0,0 +1,43 @@
+import unittest
+import dialoguer
+import rpy2.robjects as robjects
+from rpy2.robjects.packages import importr
+
+
+class TestAlt(unittest.TestCase):
+
+ # @classmethod
+ # def setUpClass(cls):
+ # source_file_path = __file__.replace('.py', '.r')
+ # cls.src_fil_r = dialoguer.Dialogue(source_file_path)
+
+ # @classmethod
+ # def tearDownClass(cls):
+ # cls.src_fil_r.close()
+
+ # def setUp(self):
+ # source_file_path = __file__.replace('.py', '.r')
+ # self.src_fil_r = dialoguer.Dialogue(source_file_path)
+
+ # def tearDown(self):
+ # self.src_fil_r.close()
+
+ def test_integer(self):
+ source_file_path = __file__.replace('.py', '.r')
+ src_fil_r = dialoguer.Dialogue(source_file_path)
+ for i in range(50000):
+ src_fil_r.assign_variable('int_i', i)
+ chk_i = src_fil_r.import_variable('int_i')
+ self.assertEqual(chk_i, i)
+ src_fil_r.close()
+
+ def test_integer_alt(self):
+ for i in range(50000):
+ robjects.r(f'int_i <- {i}')
+ chk_i = int(robjects.r['int_i'][0])
+ #chk_i = int(chk_i[0])
+ self.assertEqual(chk_i, i)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/test_alt.r b/tests/test_alt.r
new file mode 100644
index 0000000..ba6daaf
--- /dev/null
+++ b/tests/test_alt.r
@@ -0,0 +1,18 @@
+chk_0 <- TRUE
+
+add_to_vector <- function(vect_name, val) {
+ vect <- get(vect_name, envir = globalenv())
+ vect <- c(vect, val)
+ assign(vect_name, vect, envir = globalenv())
+ return(TRUE)
+}
+
+display_vector <- function(vect_name) {
+ vect <- get(vect_name, envir = globalenv())
+ display_msg(vect)
+ return(TRUE)
+}
+
+no_return_method <- function(i) {
+
+} \ No newline at end of file