capitol 0.6.3

Parse United States Congress legislative document citations
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
use crate::constants::{CDG_BASE_URL, GOVINFO_BASE_URL};
use crate::error::Error;
use crate::legislation::{Chamber, CommitteeDocumentType, Congress, MeasureType};
use crate::parser;
use crate::utils::{DisplayOption, Result};
use std::fmt::Display;
use std::str::FromStr;

/// Represents a Citation for a legislative document.
///
/// A `Citation` can represent a `Measure` (bill or resolution), an `Amendment`, a (public) `Law`, a `Statute`,
/// or a `CommitteeDocument` (congressional report or committee print).
#[derive(Clone, Debug, PartialEq)]
pub enum Citation {
    /// A `Measure` represents a bill or resolution.
    Measure {
        /// The Congress in which the measure was introduced.
        congress: Option<Congress>,
        /// The Congressional chamber of introduction.
        chamber: Chamber,
        /// The type of the Measure; `Bill`, `Resolution`, `ConcurrentResolution`, or `JointResolution`
        measure_type: MeasureType,
        /// The bill number
        number: usize,
        /// An optional suffix representing the text version of the measure.
        version: Option<String>,
    },
    /// An `Amendment` represents a change to a `Measure`.
    Amendment {
        /// The Congress in which the amendment was introduced.
        congress: Option<Congress>,
        /// The Congressional chamber of introduction.
        chamber: Chamber,
        /// The amendment number
        number: usize,
    },
    /// A `Law` represents public slip laws.
    Law {
        /// The Congress in which the measure was introduced.
        congress: Option<Congress>,
        /// The law number.
        number: usize,
    },
    /// A `Statute` represents a federal statute at large.
    Statute {
        /// The statute volume number.
        volume: usize,
        /// The statute page number.
        page: usize,
    },
    /// A `CommitteeDocument` represents a committee publication.
    CommitteeDocument {
        /// The Congress during which the document was published.
        congress: Option<Congress>,
        /// The chamber of the committee.
        chamber: Chamber,
        /// A congressional report or committee print.
        document_type: CommitteeDocumentType,
        /// The number of the document.
        number: usize,
    },
}

impl Display for Citation {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match &self {
            Self::Measure {
                chamber,
                congress,
                measure_type,
                number,
                version,
            } => {
                let mut measure = measure_type.to_string();
                if (chamber, measure_type) == (&Chamber::House, &MeasureType::Bill) {
                    measure.push('r');
                }
                write!(
                    f,
                    "{}{chamber}{measure}{number}{}",
                    DisplayOption(*congress),
                    DisplayOption(version.to_owned())
                )
            }
            Self::Amendment {
                congress,
                chamber,
                number,
            } => write!(f, "{}{chamber}amdt{number}", DisplayOption(*congress)),
            Self::Law { congress, number } => {
                write!(f, "{}pl{number}", DisplayOption(*congress))
            }
            Self::Statute { volume, page } => write!(f, "{volume}stat{page}"),
            Self::CommitteeDocument {
                congress,
                chamber,
                document_type,
                number,
            } => {
                write!(
                    f,
                    "{}{chamber}{document_type}{number}",
                    DisplayOption(*congress)
                )
            }
        }
    }
}

impl Citation {
    /// Parse a legislative citation.
    ///
    /// The method first breaks up the citation into its constituent parts, then parses each of the
    /// parts, validating that the given Congress does not exceed the current Congress.
    ///
    /// Example
    ///
    /// ```rust
    /// use capitol::Citation;
    ///
    /// let citation = Citation::parse("118hr815");
    /// ```
    ///
    /// # Errors
    ///
    /// Will result in an error if the legislative document type is unrecognized or if an integer can't be
    /// parsed from the document number.
    pub fn parse(input: &str) -> Result<Self> {
        Ok(parser::parse(input)?)
    }

    /// Render a URL for the document represented by the citation.
    /// Measures, committee documents, and laws go to Congress.gov.
    /// Statutes go to Govinfo.
    ///
    /// Example
    ///
    /// ```rust
    /// use capitol::Citation;
    ///
    /// let citation = Citation::parse("118hr815").unwrap();
    /// let url = citation.to_url();
    /// assert_eq!("https://www.congress.gov/bill/118/hr/815", url.unwrap());
    /// ```
    #[must_use]
    pub fn to_url(&self) -> Option<String> {
        match self {
            Self::Measure {
                congress,
                chamber,
                measure_type,
                number,
                version,
            } => {
                if let Some(congress) = congress {
                    let mut measure_string = measure_type.to_string();
                    if (chamber, measure_type) == (&Chamber::House, &MeasureType::Bill) {
                        measure_string.push('r');
                    }
                    let mut url = format!(
                        "{CDG_BASE_URL}/bill/{congress}/{chamber}{measure_string}/{number}"
                    );

                    if let Some(ver) = version {
                        url.push_str("/text/");
                        url.push_str(ver);
                    }
                    Some(url)
                } else {
                    None
                }
            }
            Self::Amendment {
                congress,
                chamber,
                number,
            } => congress.as_ref().map(|congress| {
                format!("{CDG_BASE_URL}/amendment/{congress}/{chamber}amdt/{number}")
            }),
            Self::CommitteeDocument {
                congress,
                chamber,
                document_type,
                number,
            } => {
                if let Some(congress) = congress {
                    let collection = match document_type {
                        CommitteeDocumentType::Report => "congressional-report",
                        CommitteeDocumentType::Print => "committee-print",
                    };
                    let url = format!(
                        "{CDG_BASE_URL}/{collection}/{congress}/{chamber}{document_type}/{number}"
                    );
                    Some(url)
                } else {
                    None
                }
            }
            Self::Statute { volume, page } => Some(format!(
                "{GOVINFO_BASE_URL}/app/details/STATUTE-{volume}/STATUTE-{volume}-Pg{page}"
            )),
            Self::Law { congress, number } => {
                if let Some(Congress(congress)) = congress {
                    Some(format!(
                        "{CDG_BASE_URL}/{congress}/plaws/publ{number}/PLAW-{congress}publ{number}.pdf"
                    ))
                } else {
                    None
                }
            }
        }
    }

    /// Returns the version of the document if it is a measure, None, otherwise.
    ///
    /// Example
    ///
    /// ```rust
    /// use capitol::Citation;
    ///
    /// let citation = Citation::parse("118hr815ih").unwrap();
    /// let version = citation.version();
    /// assert_eq!(Some("ih"), version.as_deref());
    /// ```
    #[must_use]
    pub fn version(&self) -> Option<String> {
        match self {
            Self::Measure { version, .. } => version.as_ref().map(String::from),
            _ => None,
        }
    }

    /// Returns the congress of the document if it has one, None, otherwise.
    ///
    /// Example
    ///
    /// ```rust
    /// use capitol::Citation;
    ///
    /// let citation = Citation::parse("118hr815ih").unwrap();
    /// let congress = citation.congress();
    /// assert_eq!(Some(118), congress);
    /// ```
    #[must_use]
    pub fn congress(&self) -> Option<usize> {
        match self {
            Self::Statute { .. } => None,
            Self::Measure { congress, .. }
            | Self::Amendment { congress, .. }
            | Self::Law { congress, .. }
            | Self::CommitteeDocument { congress, .. } => congress.map(|c| c.0),
        }
    }

    /// Returns the chamber of the document if it has one, None, otherwise.
    ///
    /// Example
    ///
    /// ```rust
    /// use capitol::Citation;
    ///
    /// let citation = Citation::parse("118hr815ih").unwrap();
    /// let chamber = citation.chamber();
    /// assert_eq!(Some("H"), chamber.as_deref());
    /// ```
    #[must_use]
    pub fn chamber(&self) -> Option<String> {
        match self {
            Self::Measure { chamber, .. } | Self::CommitteeDocument { chamber, .. } => {
                Some(chamber.to_string().to_uppercase())
            }
            _ => None,
        }
    }

    /// Returns the number of the document if it has one, None, otherwise.
    ///
    /// Example
    ///
    /// ```rust
    /// use capitol::Citation;
    ///
    /// let citation = Citation::parse("118hr815ih").unwrap();
    /// let number = citation.number();
    /// assert_eq!(815, number);
    /// ```
    #[must_use]
    pub fn number(&self) -> usize {
        match *self {
            Self::Statute { page, .. } => page,
            Self::Measure { number, .. }
            | Self::Amendment { number, .. }
            | Self::Law { number, .. }
            | Self::CommitteeDocument { number, .. } => number,
        }
    }

    /// Returns the volume number of the document if it is a Statute, otherwise, None.
    ///
    /// Example
    ///
    /// ```rust
    /// use capitol::Citation;
    ///
    /// let citation = Citation::parse("130stat2103").unwrap();
    /// let volume = citation.volume();
    /// assert_eq!(Some(130), volume);
    /// ```
    #[must_use]
    pub fn volume(&self) -> Option<usize> {
        if let Self::Statute { volume, .. } = *self {
            Some(volume)
        } else {
            None
        }
    }

    /// Returns the page number of the document if it is a Statute, otherwise, None.
    ///
    /// Example
    ///
    /// ```rust
    /// use capitol::Citation;
    ///
    /// let citation = Citation::parse("130stat2103").unwrap();
    /// let page = citation.page();
    /// assert_eq!(Some(2103), page);
    /// ```
    #[must_use]
    pub fn page(&self) -> Option<usize> {
        if let Self::Statute { page, .. } = *self {
            Some(page)
        } else {
            None
        }
    }

    /// Returns the citation's document type as a string.
    ///
    /// Example
    ///
    /// ```rust
    /// use capitol::Citation;
    ///
    /// let citation = Citation::parse("118hr815ih").unwrap();
    /// let document_type = citation.document_type();
    /// assert_eq!("hr", document_type);
    /// ```
    #[must_use]
    pub fn document_type(&self) -> String {
        match self {
            Self::Statute { .. } => String::from("stat"),
            Self::Amendment { .. } => String::from("amdt"),
            Self::Measure {
                chamber,
                measure_type,
                ..
            } => {
                let mut measure_string = measure_type.to_string();
                if measure_string.is_empty() {
                    measure_string.push_str(&chamber.to_string());
                    if (chamber, measure_type) == (&Chamber::House, &MeasureType::Bill) {
                        measure_string.push('r');
                    }
                }
                measure_string
            }
            Self::Law { .. } => String::from("publ"),
            Self::CommitteeDocument { document_type, .. } => document_type.to_string(),
        }
    }

    /// Returns a citation without it's version tag if a `Measure`.
    ///
    /// Example
    ///
    /// ```rust
    /// use capitol::Citation;
    ///
    /// let citation = Citation::parse("118hr815ih").unwrap();
    /// let result = citation.without_version().to_string();
    /// assert_eq!("118hr815", result);
    /// ```
    #[must_use]
    pub fn without_version(&self) -> Self {
        match self {
            Self::Measure {
                congress,
                chamber,
                measure_type,
                number,
                ..
            } => Self::Measure {
                congress: *congress,
                chamber: chamber.clone(),
                measure_type: measure_type.clone(),
                number: *number,
                version: None,
            },
            _ => self.clone(),
        }
    }

    /// Returns a citation without it's version tag if a `Law`.
    ///
    /// Example
    ///
    /// ```rust
    /// use capitol::Citation;
    ///
    /// let citation = Citation::parse("Public Law No: 119-68").unwrap();
    /// let result = citation.without_congress().to_string();
    /// assert_eq!("pl68", result);
    /// ```
    #[must_use]
    pub fn without_congress(&self) -> Self {
        match self {
            Self::Law { number, .. } => Self::Law {
                congress: None,
                number: *number,
            },
            _ => self.clone(),
        }
    }

    /// Returns true if the citation is for a `Measure`.
    ///
    /// Example
    ///
    /// ```rust
    /// use capitol::Citation;
    ///
    /// let citation = Citation::parse("118hr815ih").unwrap();
    /// assert!(citation.is_measure());
    /// ```
    #[must_use]
    pub fn is_measure(&self) -> bool {
        matches!(self, Self::Measure { .. })
    }

    /// Returns true if the citation is for a `Law`.
    ///
    /// Example
    ///
    /// ```rust
    /// use capitol::Citation;
    ///
    /// let citation = Citation::parse("Public Law No: 119-68").unwrap();
    /// assert!(citation.is_law());
    /// ```
    #[must_use]
    pub fn is_law(&self) -> bool {
        matches!(self, Self::Law { .. })
    }

    /// Returns true if the citation is for a `Statute`.
    ///
    /// Example
    ///
    /// ```rust
    /// use capitol::Citation;
    ///
    /// let citation = Citation::parse("86 Stat. 2343").unwrap();
    /// assert!(citation.is_statute());
    /// ```
    #[must_use]
    pub fn is_statute(&self) -> bool {
        matches!(self, Self::Statute { .. })
    }

    /// Returns true if the citation is for a `CommitteeDocument`.
    ///
    /// Example
    ///
    /// ```rust
    /// use capitol::Citation;
    ///
    /// let citation = Citation::parse("119hprt58246").unwrap();
    /// assert!(citation.is_committee_document());
    /// ```
    #[must_use]
    pub fn is_committee_document(&self) -> bool {
        matches!(self, Self::CommitteeDocument { .. })
    }
}

impl FromStr for Citation {
    type Err = Error;
    fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
        Self::parse(s)
    }
}

#[cfg(test)]
mod test {
    use super::*;

    #[test]
    fn test_parse_no_ver_house_bill() {
        let input = "118hr8070";
        let expected = Citation::Measure {
            congress: Some(Congress(118)),
            chamber: Chamber::House,
            measure_type: MeasureType::Bill,
            number: 8070,
            version: None,
        };
        let result = input.parse();
        assert_eq!(expected, result.unwrap());
    }

    #[test]
    fn test_parse_house_report() {
        let input = "118hrpt529";
        let expected = Citation::CommitteeDocument {
            congress: Some(Congress(118)),
            chamber: Chamber::House,
            document_type: CommitteeDocumentType::Report,
            number: 529,
        };
        let result = input.parse();
        assert_eq!(expected, result.unwrap());
    }

    #[test]
    fn test_parse_house_print() {
        let input = "119HPRT58246";
        let expected = Citation::CommitteeDocument {
            congress: Some(Congress(119)),
            chamber: Chamber::House,
            document_type: CommitteeDocumentType::Print,
            number: 58246,
        };
        let result = input.parse();
        assert_eq!(expected, result.unwrap());
    }

    #[test]
    fn test_parse_senate_print() {
        let input = "119sprt57246";
        let expected = Citation::CommitteeDocument {
            congress: Some(Congress(119)),
            chamber: Chamber::Senate,
            document_type: CommitteeDocumentType::Print,
            number: 57246,
        };
        let result = input.parse();
        assert_eq!(expected, result.unwrap());
    }

    #[test]
    fn test_parse_senate_report() {
        let input = "118srpt17";
        let expected = Citation::CommitteeDocument {
            congress: Some(Congress(118)),
            chamber: Chamber::Senate,
            document_type: CommitteeDocumentType::Report,
            number: 17,
        };
        let result = input.parse();
        assert_eq!(expected, result.unwrap());
    }

    #[test]
    fn test_house_bill_to_url() {
        let input = "118hr529";
        let expected = Some("https://www.congress.gov/bill/118/hr/529".to_string());
        let citation = input.parse::<Citation>().unwrap();
        let result = citation.to_url();
        assert_eq!(expected, result);
    }

    #[test]
    fn test_house_resolution_to_url() {
        let input = "118hres529";
        let expected = Some("https://www.congress.gov/bill/118/hres/529".to_string());
        let citation = input.parse::<Citation>().unwrap();
        let result = citation.to_url();
        assert_eq!(expected, result);
    }

    #[test]
    fn test_house_bill_with_ver_to_url() {
        let input = "118hr529ih";
        let expected = Some("https://www.congress.gov/bill/118/hr/529/text/ih".to_string());
        let citation = input.parse::<Citation>().unwrap();
        let result = citation.to_url();
        assert_eq!(expected, result);
    }

    #[test]
    fn test_house_report_to_url() {
        let input = "118hrpt529";
        let expected =
            Some("https://www.congress.gov/congressional-report/118/hrpt/529".to_string());
        let citation = input.parse::<Citation>().unwrap();
        let result = citation.to_url();
        assert_eq!(expected, result);
    }

    #[test]
    fn test_house_print_to_url() {
        let input = "119hprt58246";
        let expected = Some("https://www.congress.gov/committee-print/119/hprt/58246".to_string());
        let citation = input.parse::<Citation>().unwrap();
        let result = citation.to_url();
        assert_eq!(expected, result);
    }

    #[test]
    fn test_senate_print_to_url() {
        let input = "119sprt57246";
        let expected = Some("https://www.congress.gov/committee-print/119/sprt/57246".to_string());
        let citation = input.parse::<Citation>().unwrap();
        let result = citation.to_url();
        assert_eq!(expected, result);
    }

    #[test]
    fn test_get_version() {
        let input = "118hr529ih";
        let expected = Some("ih");
        let citation = input.parse::<Citation>().unwrap();
        let result = citation.version();
        assert_eq!(expected, result.as_deref());
    }

    #[test]
    fn test_no_congress_to_url_returns_none() {
        let input = "hr529";
        let expected = None;
        let citation = input.parse::<Citation>().unwrap();
        let result = citation.to_url();
        assert_eq!(expected, result);
    }

    #[test]
    fn test_uppercase_input() {
        let input = "118HR529IH";
        let expected = Some("https://www.congress.gov/bill/118/hr/529/text/ih".to_string());
        let citation = input.parse::<Citation>().unwrap();
        let result = citation.to_url();
        assert_eq!(expected, result);
    }

    #[test]
    fn test_parse_house_bill_with_dots() {
        let input = "118h.r.529";
        let expected = Citation::Measure {
            congress: Some(Congress(118)),
            chamber: Chamber::House,
            measure_type: MeasureType::Bill,
            number: 529,
            version: None,
        };
        let result = input.parse();
        assert_eq!(expected, result.unwrap());
    }

    #[test]
    fn test_parse_house_bill_with_version_no_congress() {
        let input = "hr529ih";
        let expected = Citation::Measure {
            congress: None,
            chamber: Chamber::House,
            measure_type: MeasureType::Bill,
            number: 529,
            version: Some("ih".to_string()),
        };
        let result = input.parse();
        assert_eq!(expected, result.unwrap());
    }

    #[test]
    fn test_print_citation_without_version() {
        let input = "118hr529ih";
        let citation: Citation = input.parse().unwrap();
        let expected = "118hr529";
        let result = citation.without_version().to_string();
        assert_eq!(expected, result);
    }

    #[test]
    fn test_print_no_congress_citation_without_version() {
        let input = "H.R.529.IH";
        let citation: Citation = input.parse().unwrap();
        let expected = "hr529".to_string();
        let result = citation.without_version().to_string();
        assert_eq!(expected, result);
    }

    #[test]
    fn test_public_law_to_string() {
        let input = "Public Law No: 119-68";
        let citation: Citation = input.parse().unwrap();
        let expected = "119pl68";
        let result = citation.to_string();
        assert_eq!(expected, result);
    }

    #[test]
    fn test_parse_public_law() {
        let input = "Public Law No: 119-68";
        let result: Citation = input.parse().unwrap();
        let expected = Citation::Law {
            congress: Some(Congress(119)),
            number: 68,
        };
        assert_eq!(expected, result);
    }

    #[test]
    fn test_statute_to_string() {
        let input = "86Stat1326";
        let citation: Citation = input.parse().unwrap();
        let expected = "86stat1326";
        let result = citation.to_string();
        assert_eq!(expected, result);
    }

    #[test]
    fn test_house_report_to_string() {
        let input = "119.H.Rpt.23";
        let citation: Citation = input.parse().unwrap();
        let expected = "119hrpt23";
        let result = citation.to_string();
        assert_eq!(expected, result);
    }

    #[test]
    fn test_normalize_senate_print() {
        let input = "119.S.Prt.23";
        let citation: Citation = input.parse().unwrap();
        let expected = "119sprt23";
        let result = citation.to_string();
        assert_eq!(expected, result);
    }

    #[test]
    fn test_statute_to_url() {
        let input = "135stat2454";
        let citation: Citation = input.parse().unwrap();
        let expected =
            Some("https://www.govinfo.gov/app/details/STATUTE-135/STATUTE-135-Pg2454".to_string());
        let result = citation.to_url();
        assert_eq!(expected, result);
    }

    #[test]
    fn test_law_to_url() {
        let input = "119pl68";
        let citation: Citation = input.parse().unwrap();
        let expected =
            Some("https://www.congress.gov/119/plaws/publ68/PLAW-119publ68.pdf".to_string());
        let result = citation.to_url();
        assert_eq!(expected, result);
        let input = "119publ68";
        let citation: Citation = input.parse().unwrap();
        let result = citation.to_url();
        assert_eq!(expected, result);
    }

    #[test]
    fn test_citations_with_spaces() {
        let input = "135 Stat. 2454";
        let citation: Citation = input.parse().unwrap();
        let expected = "135stat2454";
        let result = citation.to_string();
        assert_eq!(expected, result);
    }

    #[test]
    fn test_parse_amendment() {
        let input = "118samdt23";
        let expected = Citation::Amendment {
            congress: Some(Congress(118)),
            chamber: Chamber::Senate,
            number: 23,
        };
        let result = Citation::parse(input).unwrap();
        assert_eq!(expected, result);
    }

    #[test]
    fn test_amendment_to_url() {
        let input = "119 H.Amdt.2";
        let expected = "https://www.congress.gov/amendment/119/hamdt/2";
        let result = Citation::parse(input).unwrap().to_url().unwrap();
        assert_eq!(expected, result);
    }

    #[test]
    fn join_print_to_url() {
        let input = "118JPRT55649";
        let expected = "https://www.congress.gov/committee-print/118/jprt/55649";
        let result = Citation::parse(input).unwrap().to_url().unwrap();
        assert_eq!(expected, result);
    }
}