Skip to content

Commit 3da52fb

Browse files
committed
add ut
1 parent 5fc9837 commit 3da52fb

File tree

2 files changed

+21
-0
lines changed
  • kclvm/runtime/src/net
  • test/grammar/builtins/net/to_ip4

2 files changed

+21
-0
lines changed

kclvm/runtime/src/net/mod.rs

+19
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,25 @@ pub extern "C-unwind" fn kclvm_net_CIDR_netmask(
937937
mod test_net {
938938
use super::*;
939939

940+
#[test]
941+
#[allow(non_snake_case)]
942+
fn test_ip6_to_ip4() {
943+
let cases = [
944+
("::FFFF:192.168.1.10", "192.168.1.10"),
945+
];
946+
let mut ctx = Context::default();
947+
for (ip6, expected) in cases.iter() {
948+
unsafe {
949+
let actual = &*kclvm_net_IP6_to_IP4_string(
950+
&mut ctx,
951+
&ValueRef::list(Some(&[&ValueRef::str(ip6)])),
952+
&ValueRef::dict(None),
953+
);
954+
assert_eq!(&ValueRef::str(expected), actual, "{} positional", ip6,);
955+
}
956+
}
957+
}
958+
940959
#[test]
941960
fn test_split_host_port() {
942961
let cases = [
+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
import net
2+
13
ip0 = net.to_IP4("::FFFF:192.168.1.10")

0 commit comments

Comments
 (0)