diff --git a/src/tool/core/helpers/code_snippet.rs b/src/tool/core/helpers/code_snippet.rs index af7c359..ee47902 100644 --- a/src/tool/core/helpers/code_snippet.rs +++ b/src/tool/core/helpers/code_snippet.rs @@ -51,7 +51,7 @@ pub(crate) fn get_code_snippet_for_problem(title_slug: &str) -> anyhow::Result

anyhow::Result { let daily_challenge_response = ureq::get(Config::LEETCODE_GRAPH_QL) .send_json(ureq::json!({ - "query": r"query questionOfToday { + "query": "query questionOfToday { activeDailyCodingChallengeQuestion { question { titleSlug diff --git a/src/tool/core/helpers/problem_code.rs b/src/tool/core/helpers/problem_code.rs index ee4a3ef..2bcd52b 100644 --- a/src/tool/core/helpers/problem_code.rs +++ b/src/tool/core/helpers/problem_code.rs @@ -286,10 +286,10 @@ impl FunctionArgType { Err(e) => Err(e.to_string()), }, Self::Tree => match Self::does_pass_basic_vec_tests(line) { - Ok(()) => Ok(format!("TreeRoot::from(\"{line}\").into()")), + Ok(()) => Ok(format!(r#"TreeRoot::from("{line}").into()"#)), Err(e) => Err(e.to_string()), }, - Self::Other { raw: _ } => Ok(format!("todo!(\"{line}\")")), + Self::Other { raw: _ } => Ok(format!(r#"todo!("{line}")"#)), }; result.unwrap_or_else(|e| { warn!("Type Mismatch? Type detected as '{self:?}' but got argument value of {line:?}. Error: {e}"); @@ -586,7 +586,7 @@ impl Solution { #[test] fn get_test_case_ok() { // Arrange - let expected = "7, vec![2,3,1,2,4,3], todo!(\"Expected Result\")"; + let expected = r#"7, vec![2,3,1,2,4,3], todo!("Expected Result")"#; let fn_info = get_fn_info_min_sub_array_len(); let input = "7\n[2,3,1,2,4,3]"; @@ -725,19 +725,19 @@ impl Solution { (FAT::I64, "2"), (FAT::F64, "2.00000"), (FAT::Bool, "true"), - (FAT::String_, "\"leetcode\""), + (FAT::String_, r#""leetcode""#), (FAT::VecI32, "[1,2,3,4]"), (FAT::VecF64, "[6.00000,0.50000,-1.00000,1.00000,-1.00000]"), (FAT::VecBool, "[true,false,false,false,false]"), - (FAT::VecString, "[\"@..aA\",\"..B#.\",\"....b\"]"), + (FAT::VecString, r#"["@..aA","..B#.","....b"]"#), (FAT::VecVecI32, "[[2,2,3],[7]]"), ( FAT::VecVecString, - "[[\"java\"],[\"nodejs\"],[\"nodejs\",\"reactjs\"]]", + r#"[["java"],["nodejs"],["nodejs","reactjs"]]"#, ), ( FAT::VecVecChar, - "[[\"X\",\".\",\".\",\"X\"],[\".\",\".\",\".\",\"X\"],[\".\",\".\",\".\",\"X\"]]", + r#"[["X",".",".","X"],[".",".",".","X"],[".",".",".","X"]]"#, ), (FAT::List, "[1,2,4]"), (FAT::Tree, "[1,null,2,3]"), @@ -772,19 +772,21 @@ impl Solution { FAT::I64 => "2", FAT::F64 => "2.00000", FAT::Bool => "true", - FAT::String_ => "\"leetcode\"", + FAT::String_ => r#""leetcode""#, FAT::VecI32 => "vec![1,2,3,4]", FAT::VecF64 => "vec![6.00000,0.50000,-1.00000,1.00000,-1.00000]", FAT::VecBool => "vec![true,false,false,false,false]", - FAT::VecString => "vec![\"@..aA\".into(),\"..B#.\".into(),\"....b\".into()]", + FAT::VecString => r#"vec!["@..aA".into(),"..B#.".into(),"....b".into()]"#, FAT::VecVecI32 => "vec![vec![2,2,3],vec![7]]", FAT::VecVecString => { - "vec![vec![\"java\".into()],vec![\"nodejs\".into()],vec![\"nodejs\".into(),\"reactjs\".into()]]" + r#"vec![vec!["java".into()],vec!["nodejs".into()],vec!["nodejs".into(),"reactjs".into()]]"# + } + FAT::VecVecChar => { + "vec![vec!['X','.','.','X'],vec!['.','.','.','X'],vec!['.','.','.','X']]" } - FAT::VecVecChar => { "vec![vec!['X','.','.','X'],vec!['.','.','.','X'],vec!['.','.','.','X']]" } FAT::List => "ListHead::from(vec![1,2,4]).into()", - FAT::Tree => "TreeRoot::from(\"[1,null,2,3]\").into()", - FAT::Other { raw: _ } => "todo!(\"1\")", + FAT::Tree => r#"TreeRoot::from("[1,null,2,3]").into()"#, + FAT::Other { raw: _ } => r#"todo!("1")"#, }; let actual = fat.apply(input); assert_eq!(actual, expected);