Skip to content

Commit

Permalink
test: add tests for UNSIGNED integer
Browse files Browse the repository at this point in the history
  • Loading branch information
laysakura committed Jun 20, 2022
1 parent 931eb2d commit 6576119
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions springql-core/tests/feat_numerical_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,69 @@ fn test_feat_add_mul_float() {
assert!(approx_eq!(f64, r["answer_add"].as_f64().unwrap(), 2.5));
assert!(approx_eq!(f64, r["answer_mul"].as_f64().unwrap(), 3.0));
}

#[test]
fn test_feat_unsigned_integer() {
setup_test_logger();

let json1 = json!({
"ts": "2020-01-01 00:00:00.000000000",
});
let source_input = vec![json1];

let test_source = ForeignSource::new().unwrap();
let test_sink = ForeignSink::start().unwrap();

let ddls = vec![
"
CREATE SOURCE STREAM source_1 (
ts TIMESTAMP NOT NULL ROWTIME
);
"
.to_string(),
"
CREATE SINK STREAM sink_1 (
ts TIMESTAMP NOT NULL ROWTIME,
u32 UNSIGNED INTEGER NOT NULL
);
"
.to_string(),
"
CREATE PUMP pu_add AS
INSERT INTO sink_1 (ts, u32)
SELECT STREAM source_1.ts, 4294967295 FROM source_1;
"
.to_string(),
format!(
"
CREATE SINK WRITER tcp_sink_1 FOR sink_1
TYPE NET_CLIENT OPTIONS (
PROTOCOL 'TCP',
REMOTE_HOST '{remote_host}',
REMOTE_PORT '{remote_port}'
);
",
remote_host = test_sink.host_ip(),
remote_port = test_sink.port()
),
format!(
"
CREATE SOURCE READER tcp_1 FOR source_1
TYPE NET_CLIENT OPTIONS (
PROTOCOL 'TCP',
REMOTE_HOST '{remote_host}',
REMOTE_PORT '{remote_port}'
);
",
remote_host = test_source.host_ip(),
remote_port = test_source.port()
),
];

let _pipeline = apply_ddls(&ddls, SpringConfig::default());
test_source.start(ForeignSourceInput::new_fifo_batch(source_input));
let sink_received = drain_from_sink(&test_sink);
let r = sink_received.get(0).unwrap();

assert_eq!(r["u32"], u32::MAX);
}

0 comments on commit 6576119

Please sign in to comment.