one of the consistency tests is now passing

This commit is contained in:
Kyle Maxwell 2008-12-20 15:50:20 -08:00
parent ad28096824
commit e0e636e05c
4 changed files with 24 additions and 9 deletions

View File

@ -168,7 +168,7 @@ void __dex_recurse_foreach(struct json_object * json, char* key, struct json_obj
sprintbuf(buf, "<%s>\n", tag);
switch(json_object_get_type(val)) {
case json_type_array:
printf("arr");
// printf("arr");
inner = json_object_array_get_idx(val, 0);
switch(json_object_get_type(inner)) {
case json_type_string:
@ -187,10 +187,10 @@ void __dex_recurse_foreach(struct json_object * json, char* key, struct json_obj
}
break;
case json_type_string:
printf("str");
// printf("str");
break;
case json_type_object:
printf("obj");
// printf("obj");
break;
};
sprintbuf(buf, "</%s>\n", tag);

View File

@ -32,15 +32,15 @@ int main (int argc, char **argv) {
printbuf_file_read(fd, buf);
dexPtr dex = dex_compile(buf->buf, "");
printf("hi\n");
// printf("hi\n");
xmlDocPtr xml = dex_parse_file(dex, argv[2], 1);
printf("%s\n", xml);
printf("%s\n", dex->error);
// printf("%s\n", xml);
// printf("%s\n", dex->error);
// struct json_object *json = xml2json(xml->children->children);
// printf("%s\n", json_object_to_json_string(json));
struct json_object *json = xml2json(xml->children->children);
printf("%s\n", json_object_to_json_string(json));
xmlSaveFile("-", xml);
// xmlSaveFile("-", xml);
return 0;
}

1
fixtures/li.yelp.json Normal file
View File

@ -0,0 +1 @@
{ "foo": [ "Welcome", "\t\t\t\tAbout Me", "\t\t\t\tWrite a Review", "Find Reviews", "\t\t\t\tInvite Friends", "\t\t\t\tMessaging", "Talk", "Log In", "Account | ", "Member Search | ", "Hours:\nMon-Fri.\t\t\t\t\t11:30 a.m. - 9:00 p.m.\n\t\t\t\t\nSat-Sun.\t\t\t\t\t10:30 a.m. - 9:00 p.m.\n\t\t\t\t", "Price Range:$", "Accepts Credit Cards: No", "Parking: Street", "Attire: Casual", "Good for Groups: Yes", "Good for Kids: Yes", "Takes Reservations: No", "Delivers: No", "Take-out: Yes", "Waiter Service: No", "Wheelchair Accessible: Yes", "Outdoor Seating: Yes", "Good for: Lunch", "Alcohol: Full Bar", "4 star rating08/25/2008Sunday was beautiful and sunny even in SF.  Hubby said let's go for a ride in the convertible -…\n\t\t\t\t\t\t\tRead more »", "Restaurants | ", "Nightlife | ", "Shopping | ", "Coffee | ", "All", "Pancho's Salsa Bar &…3.5 star rating 107 reviews\n\t\t\t\tNeighborhood: Nob Hill\n\t\t\t\t\tCategory: Mexican\n\t\t", "Olivo's4 star rating 61 reviews\n\t\t\t\tNeighborhood: Nob Hill\n\t\t\t\t\tCategory: Latin American\n\t\t", "Underdog's Sports Bar &…4 star rating 111 reviews\n\t\t\t\tNeighborhood: Outer Sunset\n\t\t\t\t\tCategory: Sports Bars\n\t\t", "La Mexicana Taqueria3.5 star rating 37 reviews\n\t\t\t\tNeighborhood: Nob Hill\n\t\t\t\t\tCategory: Mexican\n\t\t", "Tortilla Heights3 star rating 254 reviews\n\t\t\t\tNeighborhood: Pacific Heights\n\t\t\t\t\tCategory: Nightlife\n\t\t", "My Favorite Places Within…Here are the fabulous places that I don't need a…\n\t\t\t\t\t", "Top RestaurantsSome of my favorite dining destinations in the…\n\t\t\t\t\t", "My New Hood!A few of the places I have tried since i moved to…\n\t\t\t\t\t", "Kiko's Top Ten Places to…Some of my favorite dining destinations in the…\n\t\t\t\t\t", "My NeighborhoodMy local dry cleaner, watering hole, deli, cafe,…\n\t\t\t\t\t", "Cheap and Easy Weeknight…Don't feel like cooking? Here's who I call for…\n\t\t\t\t\t", "Polk Me!Here's the haps on (and just off) Polk Street,…\n\t\t\t\t\t", "Strong RecommendationsLike Barry Bonds and Roger Clemens, these…\n\t\t\t\t\t", "Business Owners", " | My Account", " | About Yelp", " | FAQ", " | The Weekly Yelp", " | Yelp Blog", " | Yelp Mobile", " | Yelp Canada", " | RSS", " | Developers", " | Feedback", " | Jobs", "Site Map", " | Atlanta", " | Austin", " | Boston", " | Chicago", " | Dallas", " | Denver", " | Detroit", " | Honolulu", " | Houston", " | Las Vegas", " | Los Angeles", " | Miami", " | Minneapolis", " | New York", " | Philadelphia", " | Phoenix", " | Portland", " | Sacramento", " | San Diego", " | San Francisco", " | San Jose", " | Seattle", " | Washington, DC", " | More Cities", "Review Directories", " | Atlanta", " | Austin", " | Boston", " | Chicago", " | Dallas", " | Denver", " | Honolulu", " | Houston", " | Las Vegas", " | Los Angeles", " | Miami", " | New York", " | Philadelphia", " | Phoenix", " | Portland", " | Sacramento", " | San Diego", " | San Francisco", " | San Jose", " | Seattle", " | Washington, DC", "Talk Directories", " | Austin", " | Boston", " | Chicago", " | Los Angeles", " | New York", " | San Diego", " | San Francisco", " | San Jose", " | Seattle", " | Washington, DC", "Search Directories", " | Austin", " | Boston", " | Chicago", " | Los Angeles", " | New York", " | San Diego", " | San Francisco", " | San Jose", " | Seattle", " | Washington, DC" ] }

14
tests.rb Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env ruby
require "test/unit"
class Tests < Test::Unit::TestCase
def test_simple_array
dex_test "li.dex", "yelp.html", "li.yelp.json"
end
def dex_test(dex, input, output)
root = File.dirname(__FILE__)
fixtures = "#{root}/fixtures"
assert_equal `./dexter #{fixtures}/#{dex} #{fixtures}/#{input}`, File.read("#{fixtures}/#{output}")
end
end