def test_metric_measurements():
    '''Test that a metric measurement is what you would expect with a precise
    raw_measurement.'''
    value = Measurement(TRIG_PIN, ECHO_PIN, 20, 'metric', 2)
    value_defaults = Measurement(TRIG_PIN, ECHO_PIN)
    raw_measurement = 48.80804985408
    hole_depth = 72

    metric_distance = value.distance_metric(raw_measurement)
    metric_depth = value.depth_metric(raw_measurement, hole_depth)

    assert_equal(metric_distance, 48.81)
    assert_equal(metric_depth, 23.19)

    metric_distance = value_defaults.distance_metric(raw_measurement)
    metric_depth = value_defaults.depth_metric(raw_measurement, hole_depth)

    assert_equal(metric_distance, 48.8)
    assert_equal(metric_depth, 23.2)
示例#2
0
def test_metric_measurements():
    value = Measurement(17, 27, 20, 'metric', 1)
    raw_measurement = 48.80804985408
    hole_depth = 72

    metric_distance = value.distance_metric(raw_measurement)
    metric_depth = value.depth_metric(raw_measurement, hole_depth)

    assert_equal(metric_distance, 48.8)
    assert_equal(metric_depth, 23.2)
示例#3
0
def test_metric_measurements():
    '''Test that a metric measurement is what you would expect with a precise
    raw_measurement.'''
    value = Measurement(TRIG_PIN, ECHO_PIN, 20, 'metric', 2)
    value_defaults = Measurement(TRIG_PIN, ECHO_PIN)
    raw_measurement = 48.80804985408
    hole_depth = 72

    metric_distance = value.distance_metric(raw_measurement)
    metric_depth = value.depth_metric(raw_measurement, hole_depth)

    assert_equal(metric_distance, 48.81)
    assert_equal(metric_depth, 23.19)

    metric_distance = value_defaults.distance_metric(raw_measurement)
    metric_depth = value_defaults.depth_metric(raw_measurement, hole_depth)

    assert_equal(metric_distance, 48.8)
    assert_equal(metric_depth, 23.2)