コード例 #1
0
ファイル: XMLParserTest.cpp プロジェクト: banken/core
void mw::XMLParserTestFixture::testLoadBool_false() {
	testVar->setValue(mw::Data(M_BOOLEAN, true));
	CPPUNIT_ASSERT(testVar->getValue().getBool() == true);		
	
	
	std::string xml_text("<?xml version=\"1.0\"?>\n<monkeyml version=\"1.1\"><variable_assignments><variable_assignment variable=\"testVar\" type=\"boolean\">false</variable_assignment></variable_assignments></monkeyml>");
	writeToFile(xml_text);
	
	mw::VariableLoad::loadExperimentwideVariables(temp_xml_file_path);
	
	CPPUNIT_ASSERT(testVar->getValue().getBool() == false);			
}
コード例 #2
0
ファイル: XMLParserTest.cpp プロジェクト: banken/core
void mw::XMLParserTestFixture::testLoadFloat() {
	CPPUNIT_ASSERT(testVar->getValue().getFloat() == 0.0);		
	testVar->setValue(mw::Data(1.5));
	CPPUNIT_ASSERT(testVar->getValue().getFloat() == 1.5);		
	
	
	std::string xml_text("<?xml version=\"1.0\"?>\n<monkeyml version=\"1.1\"><variable_assignments><variable_assignment variable=\"testVar\" type=\"float\">2.5</variable_assignment></variable_assignments></monkeyml>");
	writeToFile(xml_text);
	
	mw::VariableLoad::loadExperimentwideVariables(temp_xml_file_path);
	
	CPPUNIT_ASSERT(testVar->getValue().getFloat() == 2.5);		
}
コード例 #3
0
ファイル: XMLParserTest.cpp プロジェクト: banken/core
void mw::XMLParserTestFixture::testLoadIntAttributeClosingTag() {
	CPPUNIT_ASSERT(testVar->getValue().getInteger() == 0);		
	testVar->setValue(mw::Data(1L));
	CPPUNIT_ASSERT(testVar->getValue().getInteger() == 1);		
	
	
	std::string xml_text("<?xml version=\"1.0\"?>\n<monkeyml version=\"1.1\"><variable_assignments><variable_assignment variable=\"testVar\" type=\"integer\" value=\"2\"></variable_assignment></variable_assignments></monkeyml>");
	writeToFile(xml_text);
	
	mw::VariableLoad::loadExperimentwideVariables(temp_xml_file_path);
	
	CPPUNIT_ASSERT(testVar->getValue().getInteger() == 2);		
}
コード例 #4
0
ファイル: XMLParserTest.cpp プロジェクト: banken/core
void mw::XMLParserTestFixture::testLoadStringAttribute() {
	CPPUNIT_ASSERT(testVar->getValue().getFloat() == 0.0);		
	mw::Data test_string = "test string";
	testVar->setValue(test_string);
	CPPUNIT_ASSERT(testVar->getValue() == test_string);		
	CPPUNIT_ASSERT(testVar->getValue().getString() == std::string("test string"));		
	
	
	std::string xml_text("<?xml version=\"1.0\"?>\n<monkeyml version=\"1.1\"><variable_assignments><variable_assignment variable=\"testVar\" type=\"string\" value=\"new test string\"/></variable_assignments></monkeyml>");
	writeToFile(xml_text);
	
	mw::VariableLoad::loadExperimentwideVariables(temp_xml_file_path);
	
	CPPUNIT_ASSERT(testVar->getValue().getString() == std::string("new test string"));		
}
コード例 #5
0
ファイル: test_dom_text.cpp プロジェクト: AlgoPeek/pugixml
#include "common.hpp"

#include "helpers.hpp"

#include <limits.h>

TEST_XML_FLAGS(dom_text_empty, "<node><a>foo</a><b><![CDATA[bar]]></b><c><?pi value?></c><d/></node>", parse_default | parse_pi)
{
    xml_node node = doc.child(STR("node"));

    CHECK(node.child(STR("a")).text());
    CHECK(node.child(STR("b")).text());
    CHECK(!node.child(STR("c")).text());
    CHECK(!node.child(STR("d")).text());
    CHECK(!xml_node().text());
    CHECK(!xml_text());

    generic_empty_test(node.child(STR("a")).text());
}

TEST_XML(dom_text_bool_ops, "<node>foo</node>")
{
    generic_bool_ops_test(doc.child(STR("node")).text());
}

TEST_XML_FLAGS(dom_text_get, "<node><a>foo</a><b><node/><![CDATA[bar]]></b><c><?pi value?></c><d/></node>", parse_default | parse_pi)
{
    xml_node node = doc.child(STR("node"));

    CHECK_STRING(node.child(STR("a")).text().get(), STR("foo"));
    CHECK_STRING(node.child(STR("a")).first_child().text().get(), STR("foo"));
コード例 #6
0
ファイル: log2gpx.c プロジェクト: glneo/direwolf
static void process_things (int first, int last)
{
	//printf ("process %d to %d\n", first, last);
	int i;
	int moved = 0;
	char safe_name[30];
	char safe_comment[120];

	for (i=first+1; i<=last; i++) {
	  if (things[i].lat != things[first].lat) moved = 1;
	  if (things[i].lon != things[first].lon) moved = 1;
	}

	if (moved) {

/*
 * Generate track for moving thing.
 */
	  xml_text (things[first].name, safe_name);
	  xml_text (things[first].comment, safe_comment);

	  printf ("  <trk>\n");
	  printf ("    <name>%s</name>\n", safe_name);
	  printf ("    <trkseg>\n");

	  for (i=first; i<=last; i++) {
	    printf ("      <trkpt lat=\"%.6f\" lon=\"%.6f\">\n", things[i].lat, things[i].lon);
	    if (things[i].speed != UNKNOWN_VALUE) {
	      printf ("        <speed>%.1f</speed>\n", things[i].speed);
	    }
	    if (things[i].course != UNKNOWN_VALUE) {
	      printf ("        <course>%.1f</course>\n", things[i].course);
	    }
	    if (things[i].alt != UNKNOWN_VALUE) {
	      printf ("        <ele>%.1f</ele>\n", things[i].alt);
	    }
	    if (strlen(things[i].desc) > 0) {
	      printf ("        <desc>%s</desc>\n", things[i].desc);
	    }
	    if (strlen(safe_comment) > 0) {
	      printf ("        <cmt>%s</cmt>\n", safe_comment);
	    }
	    printf ("        <time>%s</time>\n", things[i].time);
	    printf ("      </trkpt>\n");
	  }

	  printf ("    </trkseg>\n");
	  printf ("  </trk>\n");

	  /* Also generate waypoint for last location. */
	}

	// Future possibility?
	// <sym>Symbol Name</sym>	-- not standardized.

/*
 * Generate waypoint for stationary thing or last known position for moving thing.
 */
	xml_text (things[last].name, safe_name);
	xml_text (things[last].comment, safe_comment);

	printf ("  <wpt lat=\"%.6f\" lon=\"%.6f\">\n", things[last].lat, things[last].lon);
	if (things[last].alt != UNKNOWN_VALUE) {
	  printf ("    <ele>%.1f</ele>\n", things[last].alt);
	}
	if (strlen(things[i].desc) > 0) {
	  printf ("    <desc>%s</desc>\n", things[i].desc);
	}
	if (strlen(safe_comment) > 0) {
	  printf ("    <cmt>%s</cmt>\n", safe_comment);
	}
	printf ("    <name>%s</name>\n", safe_name);
	printf ("  </wpt>\n");
}