Lines
100 %
Functions
Branches
use forms::{FormValues, REPORT_BALANCE};
use nomiscript::{Value, format_value};
use rpc::chart::{ChartFormat, ChartLook};
use super::{ChartRequest, chart_call, png_from_literal};
#[test]
fn a_bytes_literal_decodes_to_its_bytes() {
let literal = format_value(&Value::Bytes(vec![0x89, b'P', b'N', b'G', 0, 255]));
assert_eq!(
png_from_literal(&literal).expect("bytes"),
vec![0x89, b'P', b'N', b'G', 0, 255]
);
}
fn a_reply_that_is_not_bytes_is_an_error() {
let err = png_from_literal("\"text\"").expect_err("not bytes");
assert!(err.to_string().contains("not a PNG"), "{err}");
let err = png_from_literal("(((").expect_err("unparsable");
fn the_chart_call_carries_form_kind_format_and_size() {
let request = ChartRequest {
kind: "bar",
format: ChartFormat::Png,
size: (640, 480),
look: ChartLook::default(),
};
chart_call(&REPORT_BALANCE, &FormValues::default(), &request),
r#"(report-chart "report-balance" "()" :kind "bar" :format "png" :width 640 :height 480 :text-px 9 :background -1)"#
fn the_chart_call_carries_the_look_as_text_height_and_rgb_integer() {
look: ChartLook {
text_px: 18,
background: Some([0x00, 0x00, 0xaa]),
},
let call = chart_call(&REPORT_BALANCE, &FormValues::default(), &request);
assert!(call.ends_with(":text-px 18 :background 170)"), "{call}");
let white = ChartRequest {
background: Some([255; 3]),
..request
let call = chart_call(&REPORT_BALANCE, &FormValues::default(), &white);
assert!(call.ends_with(":background 16777215)"), "{call}");