Skip to content

Commit

Permalink
file reading
Browse files Browse the repository at this point in the history
  • Loading branch information
PootisHunter committed Jun 19, 2024
1 parent e5ee079 commit ecbecbc
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions tests/xml_tests.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#[cfg(test)]
mod tests{

use moodle_xml::quiz::Quiz;
use moodle_xml::question::Question;
use moodle_xml::question::QuestionType;
use moodle_xml::answer::Answer;


use std::io::BufReader;
use xml::reader::EventReader;
use std::fs::File;

#[test]
fn add_quiz_xml(){
fn test_file_creation(){
let mut quiz = Quiz::new("testi_categoria".into(),None);

let shortq = QuestionType::ShortAnswer;
Expand All @@ -21,8 +23,18 @@ mod tests{
quiz.add_question(question);


assert!(quiz.quiz_xml("".into(), "testi_quiz.xml".into()).is_ok());
assert!(quiz.quiz_xml("".into(), "testi_parser.xml".into()).is_ok());

let file = File::open("testi_parser.xml").expect("Cannot open file");
let file = BufReader::new(file);

let parser = EventReader::new(file);

for e in parser{
assert!(e.is_ok())
}
}

#[test]
fn pointlimit_test(){
let mut quiz = Quiz::new("testi_categoria".into(),None);
Expand Down

0 comments on commit ecbecbc

Please sign in to comment.