Douglas W. Marshall, one of the defendants in a drug case that sparked an investigation into drug use on Capitol Hill, testified yesterday that he had both cocaine and $15,000 in cash in his bedroom on the night he was arrested for allegedly selling eight ounces of cocaine to an undercover D.C. police officer.

The testimony, which came in a pretrial hearing on motions to suppress evidence in the case, cannot be used by government prosecutors against the defendants in a trial, according to attorneys for both sides.

U.S. District Court Judge Thomas F. Hogan said he will rule in a few days on the defense attorneys' motions, which seek to prevent prosecutors from using as evidence two ounces of cocaine, the $15,000, a scale, and documents involving stock transactions seized at the Marshall home on the night of the arrest.

Marshall, 27, and codefendant Troy Todd Jr., 23, are charged with operating a cocaine distribution ring. They have pleaded not guilty to all charges.

If Marshall took the stand in a trial and contradicted anything he said yesterday under oath, the government could point to the contradictions, according to defense attorneys.

But Marshall told a reporter after his testimony that he does not expect to take the stand if the case goes to trial.

He said he decided to "get up there and tell the truth" after his lawyers told him yesterday morning that the hearing testimony could not be used against him in court.

He charged that police officers illegally confiscated two ounces of cocaine and $15,000 in cash from a filing cabinet in his room before obtaining a search warrant on the night of his arrest. The defense is not seeking to suppress evidence of another eight ounces of cocaine allegedly sold to the police officer.

The prosecution has argued that the two ounces of drugs and the money were in plain view in Marshall's room when he was arrested at his parents' house, and thus that a warrant was not needed. The prosecution also said Marshall's parents consented to a search of the house.

Todd did not testify at the hearing.

Marshall, Todd and Robert A. Finkel, 30, were arrested in April 1982 after allegedly selling cocaine to the undercover D.C. police officer, James Bradley. Finkel, who now is in the federal witness protection program, told authorities that a drug ring supplied cocaine and marijuana to congressional employes. Both Finkel and Marshall once worked on Capitol Hill.

The arrests sparked federal and congressional investigations into drug use by congressmen and Capitol Hill aides, and those probes are continuing.

Finkel and Bradley both testified at the hearings that they went together to the Marshall home, were taken by Marshall into his room and consummated a drug transaction there. The three walked out of the room together to the front door, and when the door was opened, Bradley arrested Marshall as backup police officers arrived, according to testimony by all three.

Police searched the house for Todd, whom Finkel had referred to as the "Godfather" of the operation, and found him in a lower level of the house, according to Bradley and Finkel. Todd has called the "Godfather" designation "totally ridiculous." Finkel testified yesterday that he gave Todd that nickname.

Under questioning by Assistant U.S. Attorney Daniel Bernstein, Marshall said he went into his room with 10 ounces of cocaine, but that Bradley only had enough money to buy 8 ounces.

"He Bradley had money for eight of the 10 ounces. They Bradley and Finkel were putting the cocaine in the bag, and . . . I was putting the money in the filing cabinet drawer and putting the other two ounces in that same drawer . . . ," Marshall said.

Asked if the $15,000 was his to keep, Marshall said it was not all his but that he was responsible for it at the time.

"I didn't know at that time what portion of that money would be mine and what portion belonged to Mr. Todd or what portion might belong to somebody else," Marshall testified. "I was just responsible at that moment for the money which I had taken in."