commit ccada7ece4be95584fad1c8441a534e9ab0606c1
parent 05872bb741059baae683557ab98d6a9d5e4515d9
Author: Antoine A <>
Date: Mon, 6 Jan 2025 13:23:37 +0100
taler-api: clean subject code
Diffstat:
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/taler-api/src/subject.rs b/taler-api/src/subject.rs
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2024 Taler Systems SA
+ Copyright (C) 2024-2025 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -238,7 +238,7 @@ fn parse() {
IncomingType::wad => unreachable!(),
};
let standard = &format!("{prefix}{key}");
- let (upper_l, upper_r) = standard.split_at(standard.len() / 2);
+ let (standard_l, standard_r) = standard.split_at(standard.len() / 2);
let mixed = &format!("{prefix}4mzt6RS3rvb3b0e2rdmyw0yra3y0vphyv0cyde6xbb0ympfxceg0");
let (mixed_l, mixed_r) = mixed.split_at(mixed.len() / 2);
let other_standard = &format!("{prefix}{other}");
@@ -252,7 +252,7 @@ fn parse() {
IncomingType::wad => unreachable!(),
}));
- // Check succeed if upper or mixed
+ // Check succeed if standard or mixed
for case in [standard, mixed] {
for test in [
format!("noise {case} noise"),
@@ -266,19 +266,19 @@ fn parse() {
}
}
- // Check succeed if upper or mixed and split
- for (l, r) in [(upper_l, upper_r), (mixed_l, mixed_r)] {
+ // Check succeed if standard or mixed and split
+ for (l, r) in [(standard_l, standard_r), (mixed_l, mixed_r)] {
for case in [
format!("left {l}{r} right"),
- format!("left {l} {r} right"),
- format!("left {l}-{r} right"),
- format!("left {l}+{r} right"),
- format!("left {l}\n{r} right"),
- format!("left {l}-+\n{r} right"),
- format!("left {l} - {r} right"),
- format!("left {l} + {r} right"),
- format!("left {l} \n {r} right"),
- format!("left {l} - + \n {r} right"),
+ format!("left {l} {r} right"),
+ format!("left {l}-{r} right"),
+ format!("left {l}+{r} right"),
+ format!("left {l}\n{r} right"),
+ format!("left {l}-+\n{r} right"),
+ format!("left {l} - {r} right"),
+ format!("left {l} + {r} right"),
+ format!("left {l} \n {r} right"),
+ format!("left {l} - + \n {r} right"),
] {
assert_eq!(parse_incoming_unstructured(&case), result);
}
@@ -316,7 +316,7 @@ fn parse() {
}
// Check prefer prefixed over simple
- for case in [format!("{mixed_l}-{mixed_r} {upper_l}-{upper_r}")] {
+ for case in [format!("{mixed_l}-{mixed_r} {standard_l}-{standard_r}")] {
let res = parse_incoming_unstructured(&case);
if ty == IncomingType::reserve {
assert_eq!(res, Some(IncomingSubjectResult::Ambiguous));
@@ -327,8 +327,8 @@ fn parse() {
// Check failure if malformed or missing
for case in [
- "does not contain any reserve", // Check fail if none
- &standard[0..standard.len() - 1], // Check fail if missing char
+ "does not contain any reserve", // Check fail if none
+ &standard[1..], // Check fail if missing char
"2MZT6RS3RVB3B0E2RDMYW0YRA3Y0VPHYV0CYDE6XBB0YMPFXCEG0", // Check fail if not a valid key
] {
assert_eq!(parse_incoming_unstructured(&case), None);