Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7619717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:45:27+00:00 2026-05-31T03:45:27+00:00

I wrote a parser for a non-trivial language this weekend. Some of the output

  • 0

I wrote a parser for a non-trivial language this weekend. Some of the output can be complex, even for seemingly simple input. Let’s say the input to the parser is a mathematical expression, and the output is a list of tuples that describe the input.

So the output could be 20 lines long.

How would you write the junit test? Would you run the parser, hand-check the result, and if it seems correct, drop the result into the unit test as the Right Answer?

Or is this just insane, and I need to do something differently?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:45:28+00:00Added an answer on May 31, 2026 at 3:45 am

    Ideally the idea of a “unit” test is that it tests a small unit of functionality. If the output is so complex that it’s difficult to test, that implies that you’re testing too large a unit of functionality.

    Remember that in addition to verifying that your code works, your unit tests can also act as an example of how your code should be used. A single test that just matches a result against a large predefined result probably won’t do that.

    Try to break the inner workings into smaller methods and test each one. Try to test building up a result from smaller results (e.g. if input A results in output Y, and input B results in output Z, then write a test for whether input AB results in output YZ, or whatever the appropriate result would be).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking to write some pseudo-code of a recursive descent parser. Now, I
A few weeks ago I wrote a CSV parser in python and it was
I want to use the PHP Simple HTML DOM Parser to display all my
Scala 2.8.1 I have implemented a very simple external DSL using parser/combinators for QA
I'm writing out some xml from C# using the .net framework's XmlTextWriter. This works
I'm dealing with some very non-uniform data and I'm using Ruby regular expressions to
So I wrote a parser routine to take one xml file and reparse into
I wrote a log parser that constantly reads the log file gets specific lines
I've just wrote MIME parser and tested it on 1000+ messages from my inbox,
I created a programming language and wrote it in my computer. It is an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.