aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/tests/test-basic
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_core/tests/test-basic')
-rw-r--r--mingling_core/tests/test-basic/Cargo.lock76
-rw-r--r--mingling_core/tests/test-basic/Cargo.toml10
-rw-r--r--mingling_core/tests/test-basic/tests/integration.rs93
3 files changed, 179 insertions, 0 deletions
diff --git a/mingling_core/tests/test-basic/Cargo.lock b/mingling_core/tests/test-basic/Cargo.lock
new file mode 100644
index 0000000..a5d9ab9
--- /dev/null
+++ b/mingling_core/tests/test-basic/Cargo.lock
@@ -0,0 +1,76 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 4
+
+[[package]]
+name = "just_fmt"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5454cda0d57db59778608d7a47bff5b16c6705598265869fb052b657f66cf05e"
+
+[[package]]
+name = "mingling"
+version = "0.2.0"
+dependencies = [
+ "mingling_core",
+ "mingling_macros",
+]
+
+[[package]]
+name = "mingling_core"
+version = "0.2.0"
+dependencies = [
+ "just_fmt",
+]
+
+[[package]]
+name = "mingling_macros"
+version = "0.2.0"
+dependencies = [
+ "just_fmt",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.106"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.45"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "syn"
+version = "2.0.117"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "test-basic"
+version = "0.1.0"
+dependencies = [
+ "mingling",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
diff --git a/mingling_core/tests/test-basic/Cargo.toml b/mingling_core/tests/test-basic/Cargo.toml
new file mode 100644
index 0000000..7b326c1
--- /dev/null
+++ b/mingling_core/tests/test-basic/Cargo.toml
@@ -0,0 +1,10 @@
+[package]
+name = "test-basic"
+version = "0.1.0"
+edition = "2024"
+publish = false
+
+[workspace]
+
+[dependencies]
+mingling = { path = "../../../mingling" }
diff --git a/mingling_core/tests/test-basic/tests/integration.rs b/mingling_core/tests/test-basic/tests/integration.rs
new file mode 100644
index 0000000..7cd7b8c
--- /dev/null
+++ b/mingling_core/tests/test-basic/tests/integration.rs
@@ -0,0 +1,93 @@
+use mingling::Flag;
+use mingling::NextProcess;
+use mingling::Node;
+use mingling::RenderResult;
+use mingling::StringVec;
+
+#[test]
+fn test_node_from_str() {
+ let node = Node::from("a.b.c");
+ assert_eq!(node.to_string(), "a.b.c");
+}
+
+#[test]
+fn test_node_kebab_case() {
+ let node = Node::from("HelloWorld.FooBar");
+ assert_eq!(node.to_string(), "hello-world.foo-bar");
+}
+
+#[test]
+fn test_node_join() {
+ let node = Node::from("base").join("sub");
+ assert_eq!(node.to_string(), "base.sub");
+}
+
+#[test]
+fn test_node_eq() {
+ let a = Node::from("x.y");
+ let b = Node::from("x.y");
+ let c = Node::from("x.z");
+ assert_eq!(a, b);
+ assert_ne!(a, c);
+}
+
+#[test]
+fn test_flag_from_static_str() {
+ let flag = Flag::from("-h");
+ assert_eq!(flag.as_ref(), &["-h"]);
+}
+
+#[test]
+fn test_flag_from_array() {
+ let flag = Flag::from(["-h", "--help"]);
+ assert_eq!(flag.as_ref(), &["-h", "--help"]);
+}
+
+#[test]
+fn test_flag_empty() {
+ let flag = Flag::from(());
+ assert!(flag.is_empty());
+}
+
+#[test]
+fn test_render_result_default() {
+ let r = RenderResult::default();
+ assert!(r.is_empty());
+ assert_eq!(r.exit_code, 0);
+}
+
+#[test]
+fn test_render_result_print() {
+ let mut r = RenderResult::default();
+ r.print("hello");
+ assert_eq!(&*r, "hello");
+}
+
+#[test]
+fn test_render_result_clear() {
+ let mut r = RenderResult::default();
+ r.print("data");
+ assert!(!r.is_empty());
+ r.clear();
+ assert!(r.is_empty());
+}
+
+#[test]
+fn test_next_process_display() {
+ assert_eq!(format!("{}", NextProcess::Chain), "Chain");
+ assert_eq!(format!("{}", NextProcess::Renderer), "Renderer");
+}
+
+#[test]
+fn test_string_vec_from_array() {
+ let sv = StringVec::from(["a", "b", "c"]);
+ let v: Vec<String> = sv.into();
+ assert_eq!(v, vec!["a", "b", "c"]);
+}
+
+#[test]
+fn test_string_vec_from_vec() {
+ let original = vec!["x".to_string(), "y".to_string()];
+ let sv = StringVec::from(original.clone());
+ assert_eq!(*sv, original);
+}