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

  • Home
  • SEARCH
  • 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 1073455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:59:40+00:00 2026-05-16T20:59:40+00:00

i want to undertake some unit tests and a few functional tests on a

  • 0

i want to undertake some unit tests and a few functional tests on a working system. However i have a datastructure that mostly consists of a few arrays in an object (well its fortran, so not a real object, but you get the idea.) How would an example look like to unit test a datastructure? all examples i have seen so far returned a single value that was then tested. how do i do this with a datastructure that consists of arrays?

If i could get an example in funit, that would be great. Here is an example of my datastructure:

type :: myownobject
     integer :: front(300) 
     integer :: end(300)
     integer :: size
end type

   subroutine getmesugar(myob, moredata)
      type(myownobject), intent(inout) :: myob 
      integer, intent(in) :: moredata (20)
         ! do something with myownobject 
         ! perhaps add the data after a sanity check
         ! using the new data and the object

   end subroutine

i know its perhaps a simple question, but i am really just starting out with unit testing. i am reading The Art Of Unit Testing by Roy Osherove.

  • 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-16T20:59:40+00:00Added an answer on May 16, 2026 at 8:59 pm

    Unit testing a data structure or, in more Fortranic terms, a derived data type, seems a rather vague notion. Perhaps what you want to do is test various uses of variables of derived type ?

    The way you phrase your question also suggests that you may not have learned yet how to write functions which return arrays, or am I misinterpreting what you write ? You can also write functions which return derived data types.

    Perhaps you could be more explicit about what you want to do with your type — and that might suggest what unit tests you need to write.

    EDIT: to answer OP’s comments at a little more length than a comment allows ..

    Long-term Fortran programmers, such as me, don’t really know what a unit testing framework is. I remain to be convinced that any of the frameworks which have been published, such as fUnit, will have the longevity and portability of a pure Fortran approach. What are the chances that I will still be programming in Fortran in 10 years time — quite high. What are the chances that I will be using a machine with a Ruby installation in 10 years time — quite low. So my motivation for learning fUnit is low.

    Yes, I write unit tests in Fortran. As to the testing of derived data types: I fail to see why you are having a problem with this. How do you unit test ? First you write down a set of inputs, and what outputs you expect your routine to produce if given those inputs. Then you execute the tests and compare what you get with what you expected to get. It’s as simple as that. And the size and complexity of your derived data types doesn’t alter the simplicity of the unit testing task, though it may make it more laborious without tool support.

    If you are testing large data structures and have to read and write large volumes of data a tool such as Matlab becomes very useful — you can very easily generate input data sets and compare actual and expected outputs both numerically and graphically.

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

Sidebar

Related Questions

I have a situation where I want to be able to distinguish between different
Want an applescript droplet that opens files in QuickTime and mutes them all. The
As I'm diving into RoR, I'm learning about some of the view asset tags
I want to add a row to a table, and then use it as
Want to recalculate x and y in a centered layout relative to the current
Want to update specific data in a Table Column. I can use the below
Want to know which CSS styles are currently being used on a web page.
For one of my CS classes, I and a group are writing an application
I see all the examples of AlarmManager being set by an Activity. My question
As in many web applications, when my users log into my site, I set

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.